LCL, Win32: fix 32 bit truncation of pointers in SetWindowLong/GetWindowLong. Issue #39502

This commit is contained in:
Martin 2022-01-18 21:08:26 +01:00
parent f7d2d0a690
commit defb345dc8
4 changed files with 10 additions and 10 deletions

View File

@ -67,7 +67,7 @@ var
begin
if iMsg = WM_USER + uIDTrayIcon then
begin
vwsTrayIcon := TCustomTrayIcon(PtrUInt(GetWindowLong(Handle, GWL_USERDATA)));
vwsTrayIcon := TCustomTrayIcon(PtrUInt(GetWindowLongPtrW(Handle, GWL_USERDATA)));
case LParam_ of
WM_RBUTTONUP:
begin
@ -137,13 +137,13 @@ begin
if iMsg = WM_CREATE then
begin
msgTaskbarRestart := RegisterWindowMessage('TaskbarCreated');
SetWindowLong(Handle, GWL_USERDATA, PtrInt(PCREATESTRUCT(LParam_)^.lpCreateParams));
SetWindowLongPtrW(Handle, GWL_USERDATA, PtrInt(PCREATESTRUCT(LParam_)^.lpCreateParams));
end
else
if (iMsg = msgTaskbarRestart) then
begin
// add taskbar icon
vwsTrayIcon := TCustomTrayIcon(PtrUInt(GetWindowLong(Handle, GWL_USERDATA)));
vwsTrayIcon := TCustomTrayIcon(PtrUInt(GetWindowLongPtrW(Handle, GWL_USERDATA)));
if Assigned(vwsTrayIcon) then
TWin32WSCustomTrayIcon.AddIcon(vwsTrayIcon);
end;

View File

@ -247,12 +247,12 @@ begin
WindowInfo^.WinControl := AWinControl;
AWinControl.Handle := Window;
if Assigned(SubClassWndProc) then
WindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLong(
WindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLongPtrW(
Window, GWL_WNDPROC, PtrInt(SubClassWndProc)));
// Set control ID to map WinControl. This is required for messages that sent to parent
// to extract control from the passed ID.
// In case of subclassing this ID will be set in WM_NCCREATE message handler
SetWindowLong(Window, GWL_ID, PtrInt(AWinControl));
SetWindowLongPtrW(Window, GWL_ID, PtrInt(AWinControl));
end;
if AWinControl.Font.IsDefault then
@ -274,7 +274,7 @@ begin
begin
BuddyWindowInfo := AllocWindowInfo(Buddy);
BuddyWindowInfo^.AWinControl := AWinControl;
BuddyWindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLong(
BuddyWindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLongPtrW(
Buddy, GWL_WNDPROC, PtrInt(SubClassWndProc)));
if AWinControl.Font.IsDefault then
lhFont := Win32Widgetset.DefaultFont
@ -576,7 +576,7 @@ var
begin
Handle := AWinControl.Handle;
{$ifdef RedirectDestroyMessages}
SetWindowLong(Handle, GWL_WNDPROC, PtrInt(@DestroyWindowProc));
SetWindowLongPtrW(Handle, GWL_WNDPROC, PtrInt(@DestroyWindowProc));
{$endif}
// Instead of calling DestroyWindow directly, we need to call WM_MDIDESTROY for MDI children
if Assigned(Application.MainForm) and (Application.MainForm.FormStyle=fsMDIForm) and

View File

@ -187,7 +187,7 @@ class function TWin32WSScrollBox.CreateHandle(const AWinControl: TWinControl;
WindowInfo^.needParentPaint := true;
WindowInfo^.WinControl := AWinControl;
if SubClassWndProc <> nil then
WindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLong(
WindowInfo^.DefWndProc := Windows.WNDPROC(SetWindowLongPtrW(
Window, GWL_WNDPROC, PtrInt(SubClassWndProc)));
lhFont := FDefaultFont;
Windows.SendMessage(Window, WM_SETFONT, WPARAM(lhFont), 0);}

View File

@ -392,7 +392,7 @@ begin
WindowInfo^.WinControl.Handle := Window;
WindowInfo^.DefWndProc := NCCreateParams^.DefWndProc;
WindowInfo^.needParentPaint := False;
SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
SetWindowLongPtrW(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
NCCreateParams^.Handled := True;
end;
end;
@ -723,7 +723,7 @@ begin
WindowInfo^.DefWndProc := NCCreateParams^.DefWndProc;
// listbox is not a transparent control -> no need for parentpainting
WindowInfo^.needParentPaint := False;
SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
SetWindowLongPtrW(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
NCCreateParams^.Handled := True;
end;
end;