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

View File

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

View File

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