Windows API Reference

Microsoft Developer Network (MSDN)

LPARAM

The LPARAM data type is a 32-bit signed integer value. It is used to pass data to window procedures as part of a window message. The meaning of this parameter depends on the specific window message being processed.

Type Definition

typedef long LPARAM;

Remarks

LPARAM is a parameter that can be used to send information to a window procedure. The specific data contained within an LPARAM varies greatly depending on the message being sent. For instance:

Developers must consult the documentation for each specific window message to understand the precise interpretation of its LPARAM value.

Example Usage (Conceptual)


// Example of handling WM_KEYDOWN (simplified)
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch (uMsg) {
        case WM_KEYDOWN: {
            // Extract scan code from LPARAM
            UINT scanCode = (lParam >> 16) & 0xFF;
            // Extract extended-key flag
            BOOL isExtendedKey = (lParam >> 24) & 0x01;

            if (wParam == VK_SPACE) {
                OutputDebugString(L"Spacebar pressed!\n");
            }
            // ... other key handling
            break;
        }
        // ... other messages
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
            

Note: The interpretation of LPARAM is message-dependent. Always refer to the specific message documentation for accurate usage.

Related Topics