mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 08:19:41 +02:00
customdrawn-windows: Finishes fixing the windows backend
git-svn-id: trunk@33974 -
This commit is contained in:
parent
6a8db96405
commit
bb245c48c9
@ -170,7 +170,7 @@ function LCLControlSizeNeedsUpdate(Sender: TWinControl;
|
||||
SendSizeMsgOnDiff: boolean): boolean;
|
||||
|
||||
function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean;
|
||||
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
|
||||
function GetLCLClientBoundsOffset(Handle: TWindowInfo; var Rect: TRect): boolean;
|
||||
procedure LCLBoundsToWin32Bounds(Sender: TObject;
|
||||
var Left, Top, Width, Height: Integer);
|
||||
procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer);
|
||||
@ -1210,7 +1210,7 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
|
||||
function GetLCLClientBoundsOffset(Handle: TWindowInfo; var Rect: TRect): boolean;
|
||||
var
|
||||
OwnerObject: TObject;
|
||||
begin
|
||||
|
@ -35,6 +35,15 @@ begin
|
||||
WindowClass.LPSzClassName := @ClsName;
|
||||
Result := Windows.RegisterClassW(@WindowClass) <> 0;
|
||||
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWidgetSet.WinRegister] Registered ClsName=%x', [PtrInt(Result)]));
|
||||
{$endif}
|
||||
{ WindowInfo := TWindowInfo.Create;
|
||||
WindowInfo.LCLForm := TCustomForm(AWinControl);
|
||||
WindowInfo.NativeHandle := Window;
|
||||
|
||||
AddFormWithCDHandle(WindowInfo);}
|
||||
|
||||
if Result then
|
||||
begin
|
||||
WindowClass.style := WindowClass.style or CS_SAVEBITS;
|
||||
@ -44,6 +53,9 @@ begin
|
||||
WindowClass.hbrBackground := 0;
|
||||
WindowClass.LPSzClassName := @ClsHintName;
|
||||
Result := Windows.RegisterClassW(@WindowClass) <> 0;
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWidgetSet.WinRegister] Registered ClsHintName=%x', [PtrInt(Result)]));
|
||||
{$endif}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -57,6 +69,9 @@ begin
|
||||
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
|
||||
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
|
||||
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWidgetSet.CreateAppHandle] FAppHandle=%x', [PtrInt(FAppHandle)]));
|
||||
{$endif}
|
||||
// AllocWindowInfo(FAppHandle);
|
||||
// remove useless menuitems from sysmenu
|
||||
SysMenu := Windows.GetSystemMenu(FAppHandle, False);
|
||||
|
@ -887,7 +887,7 @@ begin
|
||||
|
||||
Result := True;
|
||||
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
{$ifdef VerboseCDDrawing}
|
||||
DebugLn('Trace:< [WinAPI DeleteObject] Result=', dbgs(Result), ' ObjectType=', ObjType);
|
||||
{$endif}
|
||||
end;
|
||||
@ -2508,12 +2508,25 @@ end;*)
|
||||
coordinates are relative to the control's left and top.
|
||||
------------------------------------------------------------------------------}
|
||||
function TCDWidgetSet.GetClientBounds(handle : HWND; var ARect : TRect) : Boolean;
|
||||
var
|
||||
lObject: TObject;
|
||||
begin
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn(Format(':>[WinAPI GetClientBounds] Handle=%x', [Handle]));
|
||||
{$endif}
|
||||
// ToDO check if the window is native or not and process accordingly
|
||||
// For now just assume it is native
|
||||
Result := BackendGetClientBounds(Handle, ARect);
|
||||
Result := False;
|
||||
if Handle=0 then Exit;
|
||||
lObject := TObject(Handle);
|
||||
if lObject is TCDForm then
|
||||
Result := BackendGetClientBounds(Handle, ARect)
|
||||
else
|
||||
begin
|
||||
ARect := TCDWinControl(lObject).WinControl.BoundsRect;
|
||||
end;
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn(Format('[WinAPI GetClientBounds] ARect.Left=%d ARect.Top=%d'
|
||||
DebugLn(Format(':<[WinAPI GetClientBounds] ARect.Left=%d ARect.Top=%d'
|
||||
+ ' ARect.Right=%d ARect.Bottom=%d',
|
||||
[ARect.Left, ARect.Top, ARect.Right, ARect.Bottom]));
|
||||
{$endif}
|
||||
@ -2533,7 +2546,7 @@ end;
|
||||
function TCDWidgetSet.GetClientRect(handle : HWND; var ARect : TRect) : Boolean;
|
||||
begin
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn('[WinAPI GetClientRect]');
|
||||
DebugLn(Format('[WinAPI GetClientRect] Handle=%x', [Handle]));
|
||||
{$endif}
|
||||
GetClientBounds(Handle, ARect);
|
||||
OffsetRect(ARect, -ARect.Left, -ARect.Top);
|
||||
@ -4291,7 +4304,7 @@ begin
|
||||
ARect := Bounds(APos.X,APos.Y,R.Right-R.Left,R.Bottom-R.Top);
|
||||
|
||||
Result := -1;
|
||||
end;
|
||||
end;*)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetWindowRelativePosition
|
||||
@ -4301,19 +4314,22 @@ end;
|
||||
returns the current widget Left, Top, relative to the client origin of its
|
||||
parent
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.GetWindowRelativePosition(Handle: HWND; var Left, Top: integer): boolean;
|
||||
function TCDWidgetSet.GetWindowRelativePosition(Handle: HWND; var Left, Top: integer): boolean;
|
||||
var
|
||||
R: TRect;
|
||||
lObject: TObject;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('[WinAPI GetWindowRelativePosition]');
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn('[WinAPI GetWindowRelativePosition]');
|
||||
{$endif}
|
||||
if Handle = 0 then
|
||||
Exit(False);
|
||||
R := TQtWidget(Handle).getFrameGeometry;
|
||||
Left := R.Left;
|
||||
Top := R.Top;
|
||||
Result := True;
|
||||
if Handle = 0 then Exit(False);
|
||||
lObject := TObject(Handle);
|
||||
if lObject is TCDForm then
|
||||
begin
|
||||
Result := BackendGetWindowRelativePosition(Handle, Left, Top);
|
||||
Exit;
|
||||
end
|
||||
else
|
||||
Result := inherited GetWindowRelativePosition(Handle, Left, Top);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -4323,28 +4339,25 @@ end;
|
||||
|
||||
Returns the current widget Width and Height
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer): boolean;
|
||||
function TCDWidgetSet.GetWindowSize(Handle: hwnd; var Width, Height: integer): boolean;
|
||||
var
|
||||
lObject: TObject;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('[WinAPI GetWindowSize]');
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn('[WinAPI GetWindowSize]');
|
||||
{$endif}
|
||||
if Handle = 0 then
|
||||
Exit(False);
|
||||
|
||||
with TQtWidget(Handle).getSize do
|
||||
if Handle = 0 then Exit(False);
|
||||
lObject := TObject(Handle);
|
||||
if lObject is TCDForm then
|
||||
begin
|
||||
Height := cy;
|
||||
Width := cx;
|
||||
end;
|
||||
|
||||
Result := True;
|
||||
|
||||
// Here we should convert top level lcl window coordinaties to qt coord
|
||||
// Due to borders and etc
|
||||
// ?
|
||||
Result := BackendGetWindowSize(Handle, Width, Height);
|
||||
Exit;
|
||||
end
|
||||
else
|
||||
Result := inherited GetWindowSize(Handle, Width, Height);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
(*{------------------------------------------------------------------------------
|
||||
Function: GradientFill
|
||||
Params: DC - DeviceContext to perform on
|
||||
Vertices - array of Points W/Color & Alpha
|
||||
|
@ -1560,10 +1560,15 @@ end;*)
|
||||
function TCDWidgetSet.BackendGetClientBounds(Handle: HWND; var ARect: TRect): Boolean;
|
||||
var
|
||||
LRect: TRect;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
Result := Boolean(Windows.GetClientRect(Handle, @ARect));
|
||||
lWindowInfo := TWindowInfo(Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
|
||||
Result := Boolean(Windows.GetClientRect(lHandle, @ARect));
|
||||
if not Result then exit;
|
||||
if not GetLCLClientBoundsOffset(Handle, LRect) then exit;
|
||||
if not GetLCLClientBoundsOffset(lWindowInfo, LRect) then exit;
|
||||
Inc(ARect.Left, LRect.Left);
|
||||
Inc(ARect.Top, LRect.Top);
|
||||
Inc(ARect.Right, LRect.Right);
|
||||
@ -2172,27 +2177,32 @@ end;*)
|
||||
returns the current widget Left, Top, relative to the client origin of its
|
||||
parent
|
||||
------------------------------------------------------------------------------}
|
||||
function TCDWidgetSet.GetWindowRelativePosition(Handle: HWND;
|
||||
function TCDWidgetSet.BackendGetWindowRelativePosition(Handle: HWND;
|
||||
var Left, Top: Integer): Boolean;
|
||||
var
|
||||
LeftTop:TPoint;
|
||||
R: TRect;
|
||||
WindowPlacement: TWINDOWPLACEMENT;
|
||||
ParentHandle: THandle;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
lWindowInfo := TWindowInfo(Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
|
||||
WindowPlacement.length := SizeOf(WindowPlacement);
|
||||
if IsIconic(Handle) and GetWindowPlacement(Handle, @WindowPlacement) then
|
||||
if Windows.IsIconic(lHandle) and Windows.GetWindowPlacement(lHandle, @WindowPlacement) then
|
||||
R := WindowPlacement.rcNormalPosition
|
||||
else
|
||||
if not Windows.GetWindowRect(Handle, @R) then Exit;
|
||||
if not Windows.GetWindowRect(lHandle, @R) then Exit;
|
||||
|
||||
LeftTop.X := R.Left;
|
||||
LeftTop.Y := R.Top;
|
||||
if (GetWindowLong(Handle, GWL_STYLE) and WS_CHILD) <> 0 then
|
||||
{ if (Windows.GetWindowLong(lHandle, GWL_STYLE) and WS_CHILD) <> 0 then
|
||||
begin
|
||||
ParentHandle := Windows.GetParent(Handle);
|
||||
ParentHandle := Windows.GetParent(lHandle);
|
||||
if ParentHandle <> 0 then
|
||||
begin
|
||||
if not Windows.ScreenToClient(ParentHandle, @LeftTop) then Exit;
|
||||
@ -2201,7 +2211,7 @@ begin
|
||||
Dec(LeftTop.X, R.Left);
|
||||
Dec(LeftTop.Y, R.Top);
|
||||
end;
|
||||
end;
|
||||
end; }
|
||||
Left := LeftTop.X;
|
||||
Top := LeftTop.Y;
|
||||
Result := True;
|
||||
@ -2214,12 +2224,14 @@ end;
|
||||
|
||||
Returns the current widget Width and Height
|
||||
------------------------------------------------------------------------------}
|
||||
function TCDWidgetSet.GetWindowSize(Handle : hwnd;
|
||||
function TCDWidgetSet.BackendGetWindowSize(Handle : hwnd;
|
||||
var Width, Height: integer): boolean;
|
||||
var
|
||||
WP: WINDOWPLACEMENT;
|
||||
R: TRect;
|
||||
Info: tagWINDOWINFO;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
|
||||
procedure ExcludeCaption; inline;
|
||||
begin
|
||||
@ -2231,12 +2243,17 @@ var
|
||||
end;
|
||||
|
||||
begin
|
||||
lWindowInfo := TWindowInfo(Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
|
||||
{$ifdef VerboseCDWinAPI}
|
||||
DebugLn(Format(':>[TCDWidgetSet.GetWindowSize] Handle=%x', [Handle]));
|
||||
DebugLn(Format(':>[TCDWidgetSet.GetWindowSize] Handle=%x NativeHandle=%x', [Handle, lHandle]));
|
||||
if lWindowInfo.LCLForm <> nil then
|
||||
DebugLn(Format(':[TCDWidgetSet.GetWindowSize] lWindowInfo.LCLForm.Name=%s', [lWindowInfo.LCLForm.Name]));
|
||||
{$endif}
|
||||
|
||||
WP.length := SizeOf(WP);
|
||||
Result := Boolean(Windows.GetWindowPlacement(Handle, WP));
|
||||
Result := Boolean(Windows.GetWindowPlacement(lHandle, WP));
|
||||
|
||||
if not Result then
|
||||
begin
|
||||
@ -2258,7 +2275,7 @@ begin
|
||||
|
||||
// if it is a top level window then you can't use the normal size:
|
||||
// maximized or aero snap windows will have problems
|
||||
if (GetWindowLong(Handle, GWL_STYLE) and WS_CHILD = 0) then
|
||||
if (GetWindowLong(lHandle, GWL_STYLE) and WS_CHILD = 0) then
|
||||
begin
|
||||
FillChar(Info, SizeOf(Info), 0);
|
||||
Info.cbSize := SizeOf(Info);
|
||||
@ -2276,7 +2293,7 @@ begin
|
||||
//WriteLn('W = ', Width, ' H = ', Height);
|
||||
Exit;
|
||||
end; }
|
||||
Result := Boolean(Windows.GetWindowRect(Handle, @R));
|
||||
Result := Boolean(Windows.GetWindowRect(lHandle, @R));
|
||||
with R do
|
||||
begin
|
||||
Width := Right - Left;
|
||||
@ -2291,8 +2308,8 @@ begin
|
||||
end;
|
||||
|
||||
// convert top level lcl window coordinaties to win32 coord
|
||||
Info.dwStyle := DWORD(GetWindowLong(Handle, GWL_STYLE));
|
||||
Info.dwExStyle := DWORD(GetWindowLong(Handle, GWL_EXSTYLE));
|
||||
Info.dwStyle := DWORD(GetWindowLong(lHandle, GWL_STYLE));
|
||||
Info.dwExStyle := DWORD(GetWindowLong(lHandle, GWL_EXSTYLE));
|
||||
if (Info.dwStyle and (WS_CHILD or WS_THICKFRAME)) = WS_THICKFRAME then
|
||||
begin
|
||||
// thick, sizing border
|
||||
@ -2349,16 +2366,20 @@ function TCDWidgetSet.BackendInvalidateRect(aHandle: HWND; Rect: PRect; BErase:
|
||||
var
|
||||
Flags: UINT;
|
||||
ORect: TRect;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
lWindowInfo := TWindowInfo(AHandle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
Flags := RDW_INVALIDATE or RDW_ALLCHILDREN;
|
||||
if BErase then
|
||||
Flags := Flags or RDW_ERASE;
|
||||
if Rect <> nil then
|
||||
begin
|
||||
GetLCLClientBoundsOffset(aHandle, ORect);
|
||||
GetLCLClientBoundsOffset(lWindowInfo, ORect);
|
||||
OffsetRect(Rect^, ORect.Left, ORect.Top);
|
||||
end;
|
||||
Result := Boolean(Windows.RedrawWindow(aHandle, Rect, 0, Flags));
|
||||
Result := Boolean(Windows.RedrawWindow(lHandle, Rect, 0, Flags));
|
||||
end;
|
||||
|
||||
(*{------------------------------------------------------------------------------
|
||||
|
@ -140,7 +140,9 @@ function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override;
|
||||
function GetWindowOrgEx(dc : hdc; P : PPoint): Integer; override;
|
||||
function GetWindowRect(Handle: hwnd; var ARect: TRect): Integer; override;*)
|
||||
function GetWindowRelativePosition(Handle: hwnd; var Left, Top: Integer): boolean; override;
|
||||
function BackendGetWindowRelativePosition(Handle: hwnd; var Left, Top: Integer): boolean;
|
||||
function GetWindowSize(Handle: hwnd; var Width, Height: Integer): boolean; override;
|
||||
function BackendGetWindowSize(Handle: hwnd; var Width, Height: Integer): boolean;
|
||||
(*function GradientFill(DC: HDC; Vertices: PTriVertex; NumVertices : Longint;
|
||||
Meshes: Pointer; NumMeshes : Longint; Mode : Longint): Boolean; override;
|
||||
|
||||
|
@ -134,8 +134,9 @@ class procedure TCDWSCustomForm.WSWinControl_SetBounds(const AWinControl: TWinCo
|
||||
var
|
||||
IntfLeft, IntfTop, IntfWidth, IntfHeight: integer;
|
||||
suppressMove: boolean;
|
||||
Handle: HWND;
|
||||
WindowPlacement: TWINDOWPLACEMENT;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWSCustomForm.WSWinControl_SetBounds] AWinControl=%x'
|
||||
@ -158,15 +159,18 @@ begin
|
||||
AdaptBounds(AWinControl, IntfLeft, IntfTop, IntfWidth, IntfHeight, suppressMove);
|
||||
if not suppressMove then
|
||||
begin
|
||||
Handle := AWinControl.Handle;
|
||||
lWindowInfo := TWindowInfo(AWinControl.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
WindowPlacement.length := SizeOf(WindowPlacement);
|
||||
if IsIconic(Handle) and GetWindowPlacement(Handle, @WindowPlacement) then
|
||||
if Windows.IsIconic(lHandle) and
|
||||
Windows.GetWindowPlacement(lHandle, @WindowPlacement) then
|
||||
begin
|
||||
WindowPlacement.rcNormalPosition := Bounds(IntfLeft, IntfTop, IntfWidth, IntfHeight);
|
||||
SetWindowPlacement(Handle, @WindowPlacement);
|
||||
Windows.SetWindowPlacement(lHandle, @WindowPlacement);
|
||||
end
|
||||
else
|
||||
Windows.SetWindowPos(Handle, 0, IntfLeft, IntfTop, IntfWidth, IntfHeight, SWP_NOZORDER or SWP_NOACTIVATE);
|
||||
Windows.SetWindowPos(lHandle, 0,
|
||||
IntfLeft, IntfTop, IntfWidth, IntfHeight, SWP_NOZORDER or SWP_NOACTIVATE);
|
||||
end;
|
||||
LCLControlSizeNeedsUpdate(AWinControl, True);
|
||||
end;
|
||||
@ -276,7 +280,7 @@ begin
|
||||
//SetStdBiDiModeParams(AWinControl, Params);
|
||||
// create window
|
||||
|
||||
Window := CreateWindowExW(FlagsEx, PWideChar(WideString(pClassName)),
|
||||
Window := CreateWindowExW(FlagsEx, pClassName,
|
||||
PWideChar(WindowTitle), Flags,
|
||||
Left, Top, Width, Height, Parent, 0, HInstance, @NCCreateParams);
|
||||
|
||||
@ -290,8 +294,8 @@ begin
|
||||
WindowInfo.LCLForm := TCustomForm(AWinControl);
|
||||
WindowInfo.NativeHandle := Window;
|
||||
|
||||
//AWinControl.Handle := HWND(WindowInfo);
|
||||
AddFormWithCDHandle(WindowInfo);
|
||||
AWinControl.Handle := HWND(WindowInfo);
|
||||
Result := HWND(WindowInfo);
|
||||
|
||||
// remove system menu items for bsDialog
|
||||
@ -435,8 +439,13 @@ end;
|
||||
|
||||
class procedure TCDWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
||||
const ABorderIcons: TBorderIcons);
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
UpdateWindowStyle(AForm.Handle, CalcBorderIconsFlags(AForm),
|
||||
lWindowInfo := TWindowInfo(AForm.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
UpdateWindowStyle(lHandle, CalcBorderIconsFlags(AForm),
|
||||
WS_SYSMENU or WS_MINIMIZEBOX or WS_MAXIMIZEBOX);
|
||||
end;
|
||||
|
||||
@ -452,6 +461,8 @@ var
|
||||
AForm: TCustomForm absolute AWinControl;
|
||||
CurRect, SizeRect: Windows.RECT;
|
||||
L, T, W, H: Integer;
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format('[TCDWSCustomForm.SetBounds] AWinControl=%x'
|
||||
@ -462,6 +473,9 @@ begin
|
||||
// -> adjust size according to BorderStyle
|
||||
SizeRect := Bounds(ALeft, ATop, AWidth, AHeight);
|
||||
|
||||
lWindowInfo := TWindowInfo(AWinControl.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
|
||||
Windows.AdjustWindowRectEx(@SizeRect, CalcBorderStyleFlags(AForm) or CalcBorderIconsFlags(AForm),
|
||||
False, CalcBorderStyleFlagsEx(AForm) or CalcBorderIconsFlagsEx(AForm));
|
||||
|
||||
@ -475,7 +489,7 @@ begin
|
||||
// if position is default it will be changed to designed. We do not want this.
|
||||
if wcfInitializing in TWinControlAccess(AWinControl).FWinControlFlags then
|
||||
begin
|
||||
if Windows.GetWindowRect(AForm.Handle, CurRect) then
|
||||
if Windows.GetWindowRect(lHandle, CurRect) then
|
||||
begin
|
||||
if AForm.Position in [poDefault, poDefaultPosOnly] then
|
||||
begin
|
||||
@ -548,11 +562,16 @@ begin
|
||||
end; *)
|
||||
|
||||
class procedure TCDWSCustomForm.SetIcon(const AForm: TCustomForm; const Small, Big: HICON);
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AForm, 'SetIcon') then
|
||||
Exit;
|
||||
Windows.SendMessage(AForm.Handle, WM_SETICON, ICON_SMALL, LPARAM(Small));
|
||||
Windows.SendMessage(AForm.Handle, WM_SETICON, ICON_BIG, LPARAM(Big));
|
||||
lWindowInfo := TWindowInfo(AForm.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
Windows.SendMessage(lHandle, WM_SETICON, ICON_SMALL, LPARAM(Small));
|
||||
Windows.SendMessage(lHandle, WM_SETICON, ICON_BIG, LPARAM(Big));
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomForm.SetShowInTaskbar(const AForm: TCustomForm;
|
||||
@ -567,16 +586,26 @@ begin
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
Windows.ShowWindow(ACustomForm.Handle, SW_SHOW);
|
||||
Windows.BringWindowToTop(ACustomForm.Handle);
|
||||
lWindowInfo := TWindowInfo(ACustomForm.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
Windows.ShowWindow(lHandle, SW_SHOW);
|
||||
Windows.BringWindowToTop(lHandle);
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomForm.ShowHide(const AWinControl: TWinControl);
|
||||
const
|
||||
VisibilityToFlag: array[Boolean] of UINT = (SWP_HIDEWINDOW, SWP_SHOWWINDOW);
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
Windows.SetWindowPos(AWinControl.Handle, 0, 0, 0, 0, 0,
|
||||
lWindowInfo := TWindowInfo(AWinControl.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
Windows.SetWindowPos(lHandle, 0, 0, 0, 0, 0,
|
||||
SWP_NOSIZE or SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE or VisibilityToFlag[AWinControl.HandleObjectShouldBeVisible])
|
||||
end;
|
||||
|
||||
@ -595,18 +624,28 @@ begin
|
||||
end;
|
||||
|
||||
class procedure TCDWSCustomForm.SetText(const AWinControl: TWinControl; const AText: String);
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWincontrol, 'SetText') then Exit;
|
||||
lWindowInfo := TWindowInfo(AWinControl.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
|
||||
Windows.SetWindowTextW(AWinControl.Handle, PWideChar(UTF8Decode(AText)));
|
||||
Windows.SetWindowTextW(lHandle, PWideChar(UTF8Decode(AText)));
|
||||
end;
|
||||
|
||||
class function TCDWSCustomForm.GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean;
|
||||
var
|
||||
lWindowInfo: TWindowInfo;
|
||||
lHandle: HWND;
|
||||
begin
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(':>[TCDWSCustomForm.GetClientBounds]');
|
||||
{$endif}
|
||||
Result := LCLIntf.GetClientBounds(AWincontrol.Handle, ARect);
|
||||
lWindowInfo := TWindowInfo(AWinControl.Handle);
|
||||
lHandle := lWindowInfo.NativeHandle;
|
||||
Result := LCLIntf.GetClientBounds(lHandle, ARect);
|
||||
{$ifdef VerboseCDForms}
|
||||
DebugLn(Format(':<[TCDWSCustomForm.GetClientBounds] AWincontrol=%x Rect.left=%d Rect.Top=%d'
|
||||
+ ' Rect.Width=%d Rect.Height=%d', [PtrInt(AWincontrol), ARect.Top, ARect.Left,
|
||||
|
@ -230,7 +230,7 @@ Var
|
||||
// create a paint message
|
||||
needParentPaint := False;
|
||||
|
||||
GetWindowSize(Window, WindowWidth, WindowHeight);
|
||||
LCLIntf.GetWindowSize(HWND(WindowInfo), WindowWidth, WindowHeight);
|
||||
|
||||
// Start the double buffering by checking if we need to increase the buffer
|
||||
if (WindowInfo.BitmapWidth < WindowWidth) or (WindowInfo.BitmapHeight < WindowHeight) then
|
||||
@ -502,12 +502,12 @@ begin
|
||||
|
||||
//DebugLn('Trace:WindowProc - Getting Object with Callback Procedure');
|
||||
WindowInfo := GetWindowInfo(Window);
|
||||
|
||||
lWinControl := WindowInfo.LCLForm;
|
||||
|
||||
{$ifdef VerboseCDMessages}
|
||||
DebugLn('WindowProc lWinControl: ',DbgSName(lWinControl));
|
||||
{$endif}
|
||||
|
||||
if (IgnoreNextCharWindow <> 0) and ((Msg = WM_CHAR) or (Msg = WM_SYSCHAR)) then
|
||||
begin
|
||||
if IgnoreNextCharWindow = Window then
|
||||
@ -1239,7 +1239,7 @@ begin
|
||||
Msg := LM_NULL;
|
||||
end else
|
||||
begin
|
||||
if GetWindowRelativePosition(Window, NewLeft, NewTop) then
|
||||
if LCLIntf.GetWindowRelativePosition(HWND(WindowInfo), NewLeft, NewTop) then
|
||||
begin
|
||||
XPos := NewLeft;
|
||||
YPos := NewTop;
|
||||
@ -1272,7 +1272,7 @@ begin
|
||||
Window := Application.MainFormHandle;
|
||||
end;
|
||||
end;
|
||||
GetWindowSize(Window, NewWidth, NewHeight);
|
||||
LCLIntf.GetWindowSize(HWND(WindowInfo), NewWidth, NewHeight);
|
||||
Width := NewWidth;
|
||||
Height := NewHeight;
|
||||
if Assigned(lWinControl) then
|
||||
@ -1338,7 +1338,7 @@ begin
|
||||
// are expected.
|
||||
if (PLMsg = @LMMouseMove) and not (lWinControl is TScrollingWinControl) then
|
||||
begin
|
||||
if GetLCLClientBoundsOffset(Window, R) then
|
||||
if GetLCLClientBoundsOffset(WindowInfo, R) then
|
||||
begin
|
||||
Dec(LMMouseMove.XPos, R.Left);
|
||||
Dec(LMMouseMove.YPos, R.Top);
|
||||
@ -1346,7 +1346,7 @@ begin
|
||||
end else
|
||||
if (PLMsg = @LMMouse) and not (lWinControl is TScrollingWinControl) then
|
||||
begin
|
||||
if GetLCLClientBoundsOffset(Window, R) then
|
||||
if GetLCLClientBoundsOffset(WindowInfo, R) then
|
||||
begin
|
||||
Dec(LMMouse.XPos, R.Left);
|
||||
Dec(LMMouse.YPos, R.Top);
|
||||
|
Loading…
Reference in New Issue
Block a user