mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 23:00:35 +02:00
Several upgrades for device selection and form position/size on wince.
git-svn-id: trunk@14182 -
This commit is contained in:
parent
64c57c53d2
commit
9f6b7ab596
@ -118,14 +118,18 @@ begin
|
||||
{$ifdef VerboseWinCE}
|
||||
WriteLn('TWinCEWidgetSet.AppInit');
|
||||
{$endif}
|
||||
|
||||
|
||||
if not WinRegister then
|
||||
begin
|
||||
WriteLn('TWinCEWidgetSet.AppInit failed.');
|
||||
Exit;
|
||||
end;
|
||||
|
||||
//Init stock objects;
|
||||
{ Initializes the application type }
|
||||
if Application.ApplicationType = atDefault then
|
||||
Application.ApplicationType := GetWinCEPlatform;
|
||||
|
||||
//Init stock objects;
|
||||
FStockNullBrush := Windows.CreateSolidBrush(0);
|
||||
FStockBlackBrush := Windows.CreateSolidBrush($000000);
|
||||
FStockLtGrayBrush := Windows.CreateSolidBrush($C0C0C0);
|
||||
|
@ -91,7 +91,12 @@ function MeasureText(const AWinControl: TWinControl; Text: string; var Width, He
|
||||
function GetControlText(AHandle: HWND): string;
|
||||
|
||||
{ String functions that may be moved to the RTL in the future }
|
||||
procedure WideStrCopy(Dest, Src: PWideChar);
|
||||
function WideStrLCopy(dest, source: PWideChar; maxlen: SizeInt): PWideChar;
|
||||
function WideStrCmp(W1, W2: PWideChar): Integer;
|
||||
|
||||
{ Automatic detection of platform }
|
||||
function GetWinCEPlatform: TApplicationType;
|
||||
|
||||
type
|
||||
PDisableWindowsInfo = ^TDisableWindowsInfo;
|
||||
@ -1246,6 +1251,19 @@ begin
|
||||
SysFreeString(tmpWideStr);
|
||||
end;
|
||||
|
||||
procedure WideStrCopy(Dest, Src: PWideChar);
|
||||
var
|
||||
counter : longint;
|
||||
Begin
|
||||
counter := 0;
|
||||
while Src[counter] <> #0 do
|
||||
begin
|
||||
Dest[counter] := Src[counter];
|
||||
Inc(counter);
|
||||
end;
|
||||
Dest[counter] := #0;
|
||||
end;
|
||||
|
||||
{ Exactly equal to StrLCopy but for PWideChars
|
||||
Copyes a widestring up to a maximal length, in WideChars }
|
||||
function WideStrLCopy(dest, source: PWideChar; maxlen: SizeInt): PWideChar;
|
||||
@ -1265,6 +1283,43 @@ begin
|
||||
Result := Dest;
|
||||
end;
|
||||
|
||||
function WideStrCmp(W1, W2: PWideChar): Integer;
|
||||
var
|
||||
counter: Integer;
|
||||
Begin
|
||||
counter := 0;
|
||||
While W1[counter] = W2[counter] do
|
||||
Begin
|
||||
if (W2[counter] = #0) or (W1[counter] = #0) then
|
||||
break;
|
||||
Inc(counter);
|
||||
end;
|
||||
Result := ord(W1[counter]) - ord(W2[counter]);
|
||||
end;
|
||||
|
||||
function GetWinCEPlatform: TApplicationType;
|
||||
{$ifndef Win32}
|
||||
var
|
||||
buf: array[0..50] of WideChar;
|
||||
{$endif}
|
||||
begin
|
||||
Result := atDefault;
|
||||
|
||||
{$ifdef Win32}
|
||||
Result := atDefault;//atDesktop;
|
||||
{$else}
|
||||
if SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(buf), @buf, 0) then
|
||||
begin
|
||||
if WideStrCmp(@buf, 'PocketPC') = 0 then
|
||||
Result := atPDA
|
||||
else if WideStrCmp(@buf, 'SmartPhone') = 0 then
|
||||
Result := atSmartphone
|
||||
else if GetLastError = ERROR_ACCESS_DENIED then
|
||||
Result := atSmartphone;
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure AddToChangedMenus(Window: HWnd);
|
||||
|
@ -2581,11 +2581,6 @@ begin
|
||||
Result := Boolean(Windows.SetWindowPos(HWnd, HWndInsertAfter, X, Y, CX, CY, UFlags));
|
||||
end;
|
||||
|
||||
{function TWinCEWidgetSet.SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND; X, Y,
|
||||
cx, cy: Integer; uFlags: UINT): Boolean;
|
||||
begin
|
||||
Result:=inherited SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
|
||||
end;}
|
||||
{------------------------------------------------------------------------------
|
||||
Method: ShowCaret
|
||||
Params: HWnd - handle of window with caret
|
||||
|
@ -230,6 +230,40 @@ begin
|
||||
Flags := Flags or CalcBorderIconsFlags(AForm);
|
||||
end;
|
||||
|
||||
procedure AdjustFormBounds(const AForm: TCustomForm; var SizeRect: TRect);
|
||||
begin
|
||||
// the LCL defines the size of a form without border, win32 with.
|
||||
// -> adjust size according to BorderStyle
|
||||
SizeRect := AForm.BoundsRect;
|
||||
Windows.AdjustWindowRectEx(@SizeRect, BorderStyleToWin32Flags(
|
||||
AForm.BorderStyle), false, BorderStyleToWin32FlagsEx(AForm.BorderStyle));
|
||||
end;
|
||||
|
||||
procedure CalculateDialogPosition(var Params: TCreateWindowExParams;
|
||||
Bounds: TRect; lForm: TCustomForm);
|
||||
begin
|
||||
if lForm.Position in [poDefault, poDefaultPosOnly] then
|
||||
begin
|
||||
Params.Left := CW_USEDEFAULT;
|
||||
Params.Top := CW_USEDEFAULT;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Params.Left := Bounds.Left;
|
||||
Params.Top := Bounds.Top;
|
||||
end;
|
||||
if lForm.Position in [poDefault, poDefaultSizeOnly] then
|
||||
begin
|
||||
Params.Width := CW_USEDEFAULT;
|
||||
Params.Height := CW_USEDEFAULT;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Params.Width := Bounds.Right - Bounds.Left;
|
||||
Params.Height := Bounds.Bottom - Bounds.Top;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TWinCEWSCustomForm.CreateHandle
|
||||
Params: None
|
||||
@ -243,6 +277,8 @@ var
|
||||
Params: TCreateWindowExParams;
|
||||
LForm : TCustomForm;
|
||||
BorderStyle: TFormBorderStyle;
|
||||
WR: Windows.RECT;
|
||||
Bounds: TRect;
|
||||
begin
|
||||
{$ifdef VerboseWinCE}
|
||||
WriteLn('TWinCEWSCustomForm.CreateHandle');
|
||||
@ -263,16 +299,42 @@ begin
|
||||
SubClassWndProc := nil;
|
||||
Parent := 0;
|
||||
BorderStyle := TCustomForm(AWinControl).BorderStyle;
|
||||
if (BorderStyle <> bsDialog) and (BorderStyle <> bsNone) then
|
||||
AdjustFormBounds(lForm, Bounds);
|
||||
|
||||
if Application.ApplicationType in [atPDA, atSmartphone, atDefault] then
|
||||
begin
|
||||
Left:=CW_USEDEFAULT;
|
||||
Top:=CW_USEDEFAULT;
|
||||
Height:=CW_USEDEFAULT;
|
||||
Width:=CW_USEDEFAULT;
|
||||
{ The position and size of common windows is ignored on PDA mode,
|
||||
and a position and size that covers the whole workarea excluding
|
||||
the menu is used. The Workarea size automatically excludes the
|
||||
Taskbar.
|
||||
|
||||
Simply using CM_USEDEFAULT produces a too large Height, which
|
||||
covers the menus. So the workarea size is detected (which ignores
|
||||
the Taskbar) and then the menu is subtracted from it }
|
||||
if (BorderStyle <> bsDialog) and (BorderStyle <> bsNone) then
|
||||
begin
|
||||
Windows.SystemParametersInfo(SPI_GETWORKAREA, 0, @WR, 0);
|
||||
|
||||
Left := WR.Left;
|
||||
Top := WR.Top;
|
||||
Height := WR.Bottom - WR.Top - GetSystemMetrics(SM_CYMENU)
|
||||
- GetSystemMetrics(SM_CXBORDER) * 2;
|
||||
Width := WR.Right - WR.Left;
|
||||
end
|
||||
else
|
||||
{ On normal dialogs we need to take into consideration the size of
|
||||
the window decoration }
|
||||
begin
|
||||
Top := CW_USEDEFAULT;
|
||||
Left := CW_USEDEFAULT;
|
||||
Height := Bounds.Bottom - Bounds.Top;
|
||||
Width := Bounds.Right - Bounds.Left;
|
||||
end;
|
||||
end
|
||||
else
|
||||
//TODO:little bit dirty but works, why the captionbar height is taken from height ? what flag does that ?
|
||||
Height := Height+25;
|
||||
{ On Desktop mode we need to take into consideration the size of
|
||||
the window decoration }
|
||||
CalculateDialogPosition(Params, Bounds, lForm);
|
||||
end;
|
||||
|
||||
// create window
|
||||
|
Loading…
Reference in New Issue
Block a user