Window Procedure

From ReliCodia

(Difference between revisions)
Revision as of 19:01, 8 January 2005
216.231.56.29 (Talk | contribs)

← Previous diff
Revision as of 19:07, 8 January 2005
216.231.56.29 (Talk | contribs)

Next diff →
Line 8: Line 8:
where ''hwnd'' is the handle to the window to which the message is directed; and ''message'', ''wParam'', and ''lParam'', describe the [[API:Windows Message|Windows Message]] where ''hwnd'' is the handle to the window to which the message is directed; and ''message'', ''wParam'', and ''lParam'', describe the [[API:Windows Message|Windows Message]]
 +
 +Usually, a windows procedure is implemented as a big switch statement keyed on the ''message'' parameter. Each case executes the code that processes a given message and returns the appropriate message-specific return code in the form of ''LRESULT''. If a given message is not processed, [[API:DefWindowProc|default procedure]] should be called.

Revision as of 19:07, 8 January 2005

Window procedure is a callback function. The Windows operating system calls this function whenever an event, such as a mouse-click, a keystroke, etc., occurs. In general, a windows program is driven by such events. The information about the event is encapsulated in a Windows Message.

A separate window procedure should be written for each class of windows. The pointer to such procedure is registered with the system through Windows Class structure in the call to RegisterClass.

The signature of a window procedure must be this:

LRESULT CALLBACK MyProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

where hwnd is the handle to the window to which the message is directed; and message, wParam, and lParam, describe the Windows Message

Usually, a windows procedure is implemented as a big switch statement keyed on the message parameter. Each case executes the code that processes a given message and returns the appropriate message-specific return code in the form of LRESULT. If a given message is not processed, default procedure should be called.