windows_programming_notes.nbk: Home | Index | Next Page: GetWindowRect | Previous Page: GetWindowLong


 GetWindowLongPtr

The GetWindowLongPtr function retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory.

If you are retrieving a pointer or a handle, this function supersedes the [GetWindowLong] function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr.

    LONG_PTR GetWindowLongPtr(
        HWND hWnd,  // handle to window
        int nIndex  // offset of value to retrieve
    );

Parameters

Return Values

If the function succeeds, the return value is the requested value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

If SetWindowLong or SetWindowLongPtr has not been called previously, GetWindowLongPtr returns zero for values in the extra window or class memory.

Remarks

Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: GetWindowRect | Previous Page: GetWindowLong


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time