Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/RTL/Delphi/WinAPI    [ Add a report in this area ]  
Report #:  48771   Status: Closed
GetWindowLongPtr, SetWindowLongPtr, GWLP_* missing
Project:  Delphi Build #:  11.0.2709.7128
Version:    11.0 Submitted By:   Jordan Russell
Report Type:  Minor failure / Design problem Date Reported:  7/9/2007 11:15:12 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   252143
Resolution: Fixed (Resolution Comments) Resolved in Build: : 12.0.2872.27234
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 10
Description
GetWindowLongPtr, SetWindowLongPtr, and GWLP_* are missing from Windows.pas.
These functions/constants are needed in order to write code today that will compile cleanly on a future 64-bit version of Delphi.

Here's what must be added:

interface

const
  GWLP_WNDPROC = -4;
  GWLP_HINSTANCE = -6;
  GWLP_HWNDPARENT = -8;
  GWLP_USERDATA = -21;
  GWLP_ID = -12;

function GetWindowLongPtr(hWnd: HWND; nIndex: Integer): LONG_PTR; stdcall;
function GetWindowLongPtrA(hWnd: HWND; nIndex: Integer): LONG_PTR; stdcall;
function GetWindowLongPtrW(hWnd: HWND; nIndex: Integer): LONG_PTR; stdcall;
function SetWindowLongPtr(hWnd: HWND; nIndex: Integer; dwNewLong: LONG_PTR): LONG_PTR; stdcall;
function SetWindowLongPtrA(hWnd: HWND; nIndex: Integer; dwNewLong: LONG_PTR): LONG_PTR; stdcall;
function SetWindowLongPtrW(hWnd: HWND; nIndex: Integer; dwNewLong: LONG_PTR): LONG_PTR; stdcall;

implementation

{$IFNDEF _WIN64}
// In a 32-bit build, these are simply aliases for the non-Ptr versions.
// (WinUser.h uses macros, e.g.: #define GetWindowLongPtrA GetWindowLongA)
function GetWindowLongPtr; external user32 name 'GetWindowLongA';
function GetWindowLongPtrA; external user32 name 'GetWindowLongA';
function GetWindowLongPtrW; external user32 name 'GetWindowLongW';
function SetWindowLongPtr; external user32 name 'SetWindowLongA';
function SetWindowLongPtrA; external user32 name 'SetWindowLongA';
function SetWindowLongPtrW; external user32 name 'SetWindowLongW';
{$ELSE}
// In a 64-bit build, use the real Ptr functions.
function GetWindowLongPtr; external user32 name 'GetWindowLongPtrA';
function GetWindowLongPtrA; external user32 name 'GetWindowLongPtrA';
function GetWindowLongPtrW; external user32 name 'GetWindowLongPtrW';
function SetWindowLongPtr; external user32 name 'SetWindowLongPtrA';
function SetWindowLongPtrA; external user32 name 'SetWindowLongPtrA';
function SetWindowLongPtrW; external user32 name 'SetWindowLongPtrW';
{$ENDIF}
Steps to Reproduce:
N/A
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01