win32: don't use GWL_ID to store the control pointer because it is truncated to 32bit. Issue #39502

This commit is contained in:
Ondrej Pokorny 2022-01-19 13:39:21 +01:00
parent 92be3d6975
commit ab324f2524
3 changed files with 9 additions and 4 deletions

View File

@ -1848,13 +1848,15 @@ begin
DebugLn('WM_MEASUREITEM for a menuitem catched but menuitem is not TmenuItem'); DebugLn('WM_MEASUREITEM for a menuitem catched but menuitem is not TmenuItem');
{$endif} {$endif}
end; end;
{ Ondrej: WinAPI combobox / listbox sends WM_MEASUREITEM to its parent during CreateHandle
the GWL_ID is 32bit only - it makes problems on 64bit windows target. See issue #39502
else else
if WParam <> 0 then if WParam <> 0 then
begin begin
lWinControl := TWinControl(WParam); lWinControl := TWinControl(WParam);
//if Assigned(lWinControl) then <- already tested //if Assigned(lWinControl) then <- already tested
SetLMessageAndParams(LM_MEASUREITEM, True); SetLMessageAndParams(LM_MEASUREITEM, True);
end; end;}
end; end;
end; end;

View File

@ -252,7 +252,8 @@ begin
// 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
LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(AWinControl)); // Ondrej: the GWL_ID is 32bit only - it makes problems on 64bit windows target. See issue #39502
//LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(AWinControl));
end; end;
if AWinControl.Font.IsDefault then if AWinControl.Font.IsDefault then

View File

@ -392,7 +392,8 @@ begin
WindowInfo^.WinControl.Handle := Window; WindowInfo^.WinControl.Handle := Window;
WindowInfo^.DefWndProc := NCCreateParams^.DefWndProc; WindowInfo^.DefWndProc := NCCreateParams^.DefWndProc;
WindowInfo^.needParentPaint := False; WindowInfo^.needParentPaint := False;
LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl)); // Ondrej: the GWL_ID is 32bit only - it makes problems on 64bit windows target. See issue #39502
// LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
NCCreateParams^.Handled := True; NCCreateParams^.Handled := True;
end; end;
end; end;
@ -723,7 +724,8 @@ 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;
LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl)); // Ondrej: the GWL_ID is 32bit only - it makes problems on 64bit windows target. See issue #39502
//LCLIntf.SetWindowLong(Window, GWL_ID, PtrInt(NCCreateParams^.WinControl));
NCCreateParams^.Handled := True; NCCreateParams^.Handled := True;
end; end;
end; end;