WindowProc callback function
Applies to: desktop apps only
An application-defined function that processes messages sent to a window. The WNDPROC type defines a pointer to this callback function.
WindowProc is a placeholder for the application-defined function name.
Syntax
LRESULT CALLBACK WindowProc( __in HWND hwnd, __in UINT uMsg, __in WPARAM wParam, __in LPARAM lParam );
Parameters
- hwnd [in]
-
Type: HWND
A handle to the window.
- uMsg [in]
-
Type: UINT
The message.
For lists of the system-provided messages, see System-Defined Messages.
- wParam [in]
-
Type: WPARAM
Additional message information. The contents of this parameter depend on the value of the uMsg parameter.
- lParam [in]
-
Type: LPARAM
Additional message information. The contents of this parameter depend on the value of the uMsg parameter.
Return value
Type:
Type: LRESULT
The return value is the result of the message processing and depends on the message sent.
Remarks
If your application runs on a 32-bit version of Windows operating system, uncaught exceptions from the callback will be passed onto higher-level exception handlers of your application when available. The system then calls the unhandled exception filter to handle the exception prior to terminating the process. If the PCA is enabled, it will offer to fix the problem the next time you run the application.
However, if your application runs on a 64-bit version of Windows operating system or WOW64, you should be aware that a 64-bit operating system handles uncaught exceptions differently based on its 64-bit processor architecture, exception architecture, and calling convention. The following table summarizes all possible ways that a 64-bit Windows operating system or WOW64 handles uncaught exceptions.
| Behavior type | How the system handles uncaught exceptions |
|---|---|
| 1 | The system suppresses any uncaught exceptions. |
| 2 | The system first terminates the process, and then the Program Compatibility Assistant (PCA) offers to fix it the next time you run the application. You can disable the PCA mitigation by adding a Compatibility section to the application manifest. |
| 3 | The system calls the exception filters but suppresses any uncaught exceptions when it leaves the callback scope, without invoking the associated handlers. |
The following table shows how a 64-bit version of Windows operating system or WOW64 handles uncaught exceptions. Notice that behavior type 2 only applies to the 64-bit version of the Windows 7 operating system.
| Operating System | WOW64 | 64-bit Windows |
|---|---|---|
| Windows XP | 3 | 1 |
| Windows Server 2003 | 3 | 1 |
| Windows Vista | 3 | 1 |
| Windows Vista SP1 | 1 | 1 |
| Windows 7 | 1 | 2 |
Note On Windows 7 with SP1 (32-bit, 64-bit or WOW64), the system calls the unhandled exception filter to handle the exception prior to terminating the process. If the PCA is enabled, it will offer to fix the problem the next time you run the application.
If you need to handle exceptions in your application, you can use structured exception handling to do so. For more information on how to use structured exception handling, see Structured Exception Handling.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
See also
- Reference
- CallWindowProc
- DefWindowProc
- RegisterClass
- Conceptual
- Window Procedures
Send comments about this topic to Microsoft
Build date: 2/3/2012