WindowProc ( WPARAM and LPARAM)
WindowProc: The WindowProc function is an application-defined function that processes messages sent to a window. WPARAM and LPARAM are third and forth parameter in WindowProc() callback. Both WPARAM and LPARAM are dependent on message identifier. For some message identifiers these has values and for some others these are either NULL or 0.Parameters
- hwnd - Handle to the window.
- uMsg - Specifies the message.
- wParam - Specifies additional message information. The contents of this parameter depend on the value of the uMsg parameter.
- lParam - Specifies additional message information. The contents of this parameter depend on the value of the uMsg parameter.
What do the prefix letter W and L stand for in WPARAM and LPARAM?
The W in WPARAM stands for WORD and the L in LPARAM stands for LONG. These two parameters are the two parameters for the uMsg message code.
WM_MOUSEMOVE (WPARAM LPARAM)
WM_MOUSEMOVE uses all the parameters. This is one good example to describe how WPARAM and LPARAMs are used. Mouse move or WM_MOUSEMOVE message has the following meaning for WPARAM and LPARAM.
Message: WM_MOUSEMOVE Mouse+Ctrl Kyes: fwKeys = wParam; Mouse horizontal position: xPos = LOWORD(lParam); Mouse vertical position: yPos = HIWORD(lParam);
WM_MOUSEMOVE (WPARAM LPARAM) demo
We have pressed control key, shift key and left mouse key along with moved the mouse on the window.
About our authors: Team EQA
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...
Learn on Youtube