Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WindowProc callback function

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
1The 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 SystemWOW6464-bit Windows
Windows XP31
Windows Server 200331
Windows Vista31
Windows Vista SP111
Windows 712

 

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 [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

See also

Reference
CallWindowProc
DefWindowProc
RegisterClass
Conceptual
Window Procedures

 

 

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft