mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-12 20:40:31 +01: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
@ -125,6 +125,10 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ Initializes the application type }
|
||||||
|
if Application.ApplicationType = atDefault then
|
||||||
|
Application.ApplicationType := GetWinCEPlatform;
|
||||||
|
|
||||||
//Init stock objects;
|
//Init stock objects;
|
||||||
FStockNullBrush := Windows.CreateSolidBrush(0);
|
FStockNullBrush := Windows.CreateSolidBrush(0);
|
||||||
FStockBlackBrush := Windows.CreateSolidBrush($000000);
|
FStockBlackBrush := Windows.CreateSolidBrush($000000);
|
||||||
|
|||||||
@ -91,7 +91,12 @@ function MeasureText(const AWinControl: TWinControl; Text: string; var Width, He
|
|||||||
function GetControlText(AHandle: HWND): string;
|
function GetControlText(AHandle: HWND): string;
|
||||||
|
|
||||||
{ String functions that may be moved to the RTL in the future }
|
{ 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 WideStrLCopy(dest, source: PWideChar; maxlen: SizeInt): PWideChar;
|
||||||
|
function WideStrCmp(W1, W2: PWideChar): Integer;
|
||||||
|
|
||||||
|
{ Automatic detection of platform }
|
||||||
|
function GetWinCEPlatform: TApplicationType;
|
||||||
|
|
||||||
type
|
type
|
||||||
PDisableWindowsInfo = ^TDisableWindowsInfo;
|
PDisableWindowsInfo = ^TDisableWindowsInfo;
|
||||||
@ -1246,6 +1251,19 @@ begin
|
|||||||
SysFreeString(tmpWideStr);
|
SysFreeString(tmpWideStr);
|
||||||
end;
|
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
|
{ Exactly equal to StrLCopy but for PWideChars
|
||||||
Copyes a widestring up to a maximal length, in WideChars }
|
Copyes a widestring up to a maximal length, in WideChars }
|
||||||
function WideStrLCopy(dest, source: PWideChar; maxlen: SizeInt): PWideChar;
|
function WideStrLCopy(dest, source: PWideChar; maxlen: SizeInt): PWideChar;
|
||||||
@ -1265,6 +1283,43 @@ begin
|
|||||||
Result := Dest;
|
Result := Dest;
|
||||||
end;
|
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);
|
procedure AddToChangedMenus(Window: HWnd);
|
||||||
|
|||||||
@ -2581,11 +2581,6 @@ begin
|
|||||||
Result := Boolean(Windows.SetWindowPos(HWnd, HWndInsertAfter, X, Y, CX, CY, UFlags));
|
Result := Boolean(Windows.SetWindowPos(HWnd, HWndInsertAfter, X, Y, CX, CY, UFlags));
|
||||||
end;
|
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
|
Method: ShowCaret
|
||||||
Params: HWnd - handle of window with caret
|
Params: HWnd - handle of window with caret
|
||||||
|
|||||||
@ -230,6 +230,40 @@ begin
|
|||||||
Flags := Flags or CalcBorderIconsFlags(AForm);
|
Flags := Flags or CalcBorderIconsFlags(AForm);
|
||||||
end;
|
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
|
Method: TWinCEWSCustomForm.CreateHandle
|
||||||
Params: None
|
Params: None
|
||||||
@ -243,6 +277,8 @@ var
|
|||||||
Params: TCreateWindowExParams;
|
Params: TCreateWindowExParams;
|
||||||
LForm : TCustomForm;
|
LForm : TCustomForm;
|
||||||
BorderStyle: TFormBorderStyle;
|
BorderStyle: TFormBorderStyle;
|
||||||
|
WR: Windows.RECT;
|
||||||
|
Bounds: TRect;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseWinCE}
|
{$ifdef VerboseWinCE}
|
||||||
WriteLn('TWinCEWSCustomForm.CreateHandle');
|
WriteLn('TWinCEWSCustomForm.CreateHandle');
|
||||||
@ -263,16 +299,42 @@ begin
|
|||||||
SubClassWndProc := nil;
|
SubClassWndProc := nil;
|
||||||
Parent := 0;
|
Parent := 0;
|
||||||
BorderStyle := TCustomForm(AWinControl).BorderStyle;
|
BorderStyle := TCustomForm(AWinControl).BorderStyle;
|
||||||
|
AdjustFormBounds(lForm, Bounds);
|
||||||
|
|
||||||
|
if Application.ApplicationType in [atPDA, atSmartphone, atDefault] then
|
||||||
|
begin
|
||||||
|
{ 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
|
if (BorderStyle <> bsDialog) and (BorderStyle <> bsNone) then
|
||||||
begin
|
begin
|
||||||
Left:=CW_USEDEFAULT;
|
Windows.SystemParametersInfo(SPI_GETWORKAREA, 0, @WR, 0);
|
||||||
Top:=CW_USEDEFAULT;
|
|
||||||
Height:=CW_USEDEFAULT;
|
Left := WR.Left;
|
||||||
Width:=CW_USEDEFAULT;
|
Top := WR.Top;
|
||||||
|
Height := WR.Bottom - WR.Top - GetSystemMetrics(SM_CYMENU)
|
||||||
|
- GetSystemMetrics(SM_CXBORDER) * 2;
|
||||||
|
Width := WR.Right - WR.Left;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
//TODO:little bit dirty but works, why the captionbar height is taken from height ? what flag does that ?
|
{ On normal dialogs we need to take into consideration the size of
|
||||||
Height := Height+25;
|
the window decoration }
|
||||||
|
begin
|
||||||
|
Top := CW_USEDEFAULT;
|
||||||
|
Left := CW_USEDEFAULT;
|
||||||
|
Height := Bounds.Bottom - Bounds.Top;
|
||||||
|
Width := Bounds.Right - Bounds.Left;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{ On Desktop mode we need to take into consideration the size of
|
||||||
|
the window decoration }
|
||||||
|
CalculateDialogPosition(Params, Bounds, lForm);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// create window
|
// create window
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user