Microsoft Docs – Windows API

DefWindowProc

The DefWindowProc function calls the default window procedure to provide default processing for any window messages that an application does not process. This function ensures standard behavior for windows that your program creates.

Syntax

LRESULT DefWindowProc(
    HWND   hWnd,
    UINT   Msg,
    WPARAM wParam,
    LPARAM lParam
);

Parameters

ParameterTypeDescription
hWndHWNDHandle to the window receiving the message.
MsgUINTMessage identifier.
wParamWPARAMAdditional message information. The content of this parameter depends on the value of Msg.
lParamLPARAMAdditional message information. The content of this parameter depends on the value of Msg.

Return Value

The return value is a LRESULT that indicates the result of message processing. Its meaning depends on the message specified by Msg.

Remarks

Example

#include <windows.h>

LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_CREATE:
            // Initialization code here
            return 0;

        case WM_PAINT:
            // Paint handling here
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        default:
            // Let the default window procedure handle everything else
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
}

See Also