mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 12:59:19 +02:00
wince: port win32 modal forms handling
git-svn-id: trunk@18656 -
This commit is contained in:
parent
6547cc249c
commit
d94aea3830
@ -130,6 +130,7 @@ var
|
|||||||
DoubleBufferBitmap: HBITMAP = 0;
|
DoubleBufferBitmap: HBITMAP = 0;
|
||||||
DoubleBufferBitmapWidth: integer = 0;
|
DoubleBufferBitmapWidth: integer = 0;
|
||||||
DoubleBufferBitmapHeight: integer = 0;
|
DoubleBufferBitmapHeight: integer = 0;
|
||||||
|
DisabledForms: TList = nil;
|
||||||
|
|
||||||
function CheckMouseMovement: boolean;
|
function CheckMouseMovement: boolean;
|
||||||
// returns true if mouse did not move between lmousebutton down
|
// returns true if mouse did not move between lmousebutton down
|
||||||
@ -1301,15 +1302,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
WM_ENABLE:
|
WM_ENABLE:
|
||||||
begin
|
begin
|
||||||
If WParam <> 0 Then
|
if WParam <> 0 then
|
||||||
LMessage.Msg := LM_SETEDITABLE;
|
LMessage.Msg := LM_SETEDITABLE;
|
||||||
If Window=TWinCEWidgetSet(WidgetSet).FAppHandle then
|
if Window = TWinCEWidgetSet(WidgetSet).FAppHandle then
|
||||||
if WParam=0 then
|
if WParam = 0 then
|
||||||
DisableApplicationWindows(Window)
|
DisabledForms := Screen.DisableForms(nil, DisabledForms)
|
||||||
else
|
else
|
||||||
EnableApplicationWindows(Window);
|
Screen.EnableForms(DisabledForms);
|
||||||
|
|
||||||
If (lWinControl is TCustomFloatSpinEdit) then
|
if (lWinControl is TCustomFloatSpinEdit) then
|
||||||
EnableFloatSpinEditBuddy(Window, WParam<>0);
|
EnableFloatSpinEditBuddy(Window, WParam<>0);
|
||||||
end;
|
end;
|
||||||
WM_ERASEBKGND:
|
WM_ERASEBKGND:
|
||||||
|
@ -168,7 +168,7 @@ type
|
|||||||
|
|
||||||
function WinRegister: Boolean;
|
function WinRegister: Boolean;
|
||||||
|
|
||||||
Public
|
public
|
||||||
{ Creates a callback of Lazarus message Msg for Sender }
|
{ Creates a callback of Lazarus message Msg for Sender }
|
||||||
procedure SetCallback(Msg: LongInt; Sender: TObject); virtual;
|
procedure SetCallback(Msg: LongInt; Sender: TObject); virtual;
|
||||||
{ Removes all callbacks for Sender }
|
{ Removes all callbacks for Sender }
|
||||||
@ -180,6 +180,7 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function LCLPlatform: TLCLPlatform; override;
|
function LCLPlatform: TLCLPlatform; override;
|
||||||
|
function GetLCLCapability(ACapability: TLCLCapability): PtrUInt; override;
|
||||||
|
|
||||||
{ Initialize the API }
|
{ Initialize the API }
|
||||||
procedure AppInit(var ScreenInfo: TScreenInfo); override;
|
procedure AppInit(var ScreenInfo: TScreenInfo); override;
|
||||||
|
@ -443,6 +443,15 @@ begin
|
|||||||
Result:= lpWinCE;
|
Result:= lpWinCE;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TWinCEWidgetSet.GetLCLCapability(ACapability: TLCLCapability): PtrUInt;
|
||||||
|
begin
|
||||||
|
case ACapability of
|
||||||
|
lcModalWindow: Result := 0;
|
||||||
|
else
|
||||||
|
Result := inherited;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function: CreateTimer
|
function: CreateTimer
|
||||||
Params: Interval:
|
Params: Interval:
|
||||||
|
@ -32,7 +32,6 @@ type
|
|||||||
PWinControl: TWinControl; // control to paint for
|
PWinControl: TWinControl; // control to paint for
|
||||||
AWinControl: TWinControl; // control associated with (for buddy controls)
|
AWinControl: TWinControl; // control associated with (for buddy controls)
|
||||||
List: TStrings;
|
List: TStrings;
|
||||||
DisabledWindowList: TList;// a list of windows that were disabled when showing modal
|
|
||||||
needParentPaint: boolean; // has a tabpage as parent, and is winxp themed
|
needParentPaint: boolean; // has a tabpage as parent, and is winxp themed
|
||||||
isTabPage: boolean; // is window of tabpage
|
isTabPage: boolean; // is window of tabpage
|
||||||
isComboEdit: boolean; // is buddy of combobox, the edit control
|
isComboEdit: boolean; // is buddy of combobox, the edit control
|
||||||
@ -90,9 +89,6 @@ function GetFileVersion(FileName: string): dword;
|
|||||||
function AllocWindowInfo(Window: HWND): PWindowInfo;
|
function AllocWindowInfo(Window: HWND): PWindowInfo;
|
||||||
function DisposeWindowInfo(Window: HWND): boolean;
|
function DisposeWindowInfo(Window: HWND): boolean;
|
||||||
function GetWindowInfo(Window: HWND): PWindowInfo;
|
function GetWindowInfo(Window: HWND): PWindowInfo;
|
||||||
function DisableWindowsProc(Window: HWND; Data: LParam): LongBool; {$ifdef Win32}stdcall;{$else}cdecl;{$endif}
|
|
||||||
procedure DisableApplicationWindows(Window: HWND);
|
|
||||||
procedure EnableApplicationWindows(Window: HWND);
|
|
||||||
procedure AddToChangedMenus(Window: HWnd);
|
procedure AddToChangedMenus(Window: HWnd);
|
||||||
procedure RedrawMenus;
|
procedure RedrawMenus;
|
||||||
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
|
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
|
||||||
@ -106,14 +102,6 @@ function WideStrCmp(W1, W2: PWideChar): Integer;
|
|||||||
{ Automatic detection of platform }
|
{ Automatic detection of platform }
|
||||||
function GetWinCEPlatform: TApplicationType;
|
function GetWinCEPlatform: TApplicationType;
|
||||||
|
|
||||||
type
|
|
||||||
PDisableWindowsInfo = ^TDisableWindowsInfo;
|
|
||||||
TDisableWindowsInfo = record
|
|
||||||
NewModalWindow: HWND;
|
|
||||||
ProcessID: DWORD;
|
|
||||||
DisabledWindowList: TList;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
DefaultWindowInfo: TWindowInfo;
|
DefaultWindowInfo: TWindowInfo;
|
||||||
OverwriteCheck: Integer = 0;
|
OverwriteCheck: Integer = 0;
|
||||||
@ -1232,10 +1220,7 @@ begin
|
|||||||
WindowInfo := PWindowInfo(WinCEExtra.GetProp(Window{, PChar(dword(WindowInfoAtom))}));
|
WindowInfo := PWindowInfo(WinCEExtra.GetProp(Window{, PChar(dword(WindowInfoAtom))}));
|
||||||
Result := WinCEExtra.RemoveProp(Window{, PChar(dword(WindowInfoAtom))})<>0;
|
Result := WinCEExtra.RemoveProp(Window{, PChar(dword(WindowInfoAtom))})<>0;
|
||||||
if Result then
|
if Result then
|
||||||
begin
|
|
||||||
WindowInfo^.DisabledWindowList.Free;
|
|
||||||
Dispose(WindowInfo);
|
Dispose(WindowInfo);
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetWindowInfo(Window: HWND): PWindowInfo;
|
function GetWindowInfo(Window: HWND): PWindowInfo;
|
||||||
@ -1287,80 +1272,6 @@ begin
|
|||||||
'Window = ' + IntToStr(Window) + ' ClassName = ' + WndClassName(Window) + ' Thread id = ' + IntToStr(GetWindowThreadProcessId(Window, nil)));
|
'Window = ' + IntToStr(Window) + ' ClassName = ' + WndClassName(Window) + ' Thread id = ' + IntToStr(GetWindowThreadProcessId(Window, nil)));
|
||||||
end;}
|
end;}
|
||||||
|
|
||||||
{-----------------------------------------------------------------------------
|
|
||||||
Function: DisableWindowsProc
|
|
||||||
Params: Window - handle of toplevel windows to be disabled
|
|
||||||
Data - handle of current window form
|
|
||||||
Returns: True if the enumeration should continue, False otherwise
|
|
||||||
|
|
||||||
Used in LM_SHOWMODAL to disable the windows of application thread
|
|
||||||
except the current form.
|
|
||||||
-----------------------------------------------------------------------------}
|
|
||||||
function DisableWindowsProc(Window: HWND; Data: LParam): LongBool; {$ifdef Win32}stdcall;{$else}cdecl;{$endif}
|
|
||||||
var
|
|
||||||
DisableWindowsInfo: PDisableWindowsInfo absolute Data;
|
|
||||||
begin
|
|
||||||
Result := True;
|
|
||||||
|
|
||||||
// Only disable windows from our application
|
|
||||||
if DisableWindowsInfo^.ProcessID <> GetWindowThreadProcessId(Window, nil) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
// Don't disable the current window form or menu of that form
|
|
||||||
if (Window = DisableWindowsInfo^.NewModalWindow) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
if not IsWindowVisible(Window) or
|
|
||||||
not IsWindowEnabled(Window) or
|
|
||||||
IsAlienWindow(Window) then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
DisableWindowsInfo^.DisabledWindowList.Add(Pointer(Window));
|
|
||||||
//LogWindow(Window);
|
|
||||||
EnableWindow(Window, False);
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
|
||||||
InDisableApplicationWindows: boolean = false;
|
|
||||||
|
|
||||||
procedure DisableApplicationWindows(Window: HWND);
|
|
||||||
var
|
|
||||||
DisableWindowsInfo: PDisableWindowsInfo;
|
|
||||||
WindowInfo: PWindowInfo;
|
|
||||||
begin
|
|
||||||
// prevent recursive calling when the AppHandle window is disabled
|
|
||||||
if InDisableApplicationWindows then exit;
|
|
||||||
InDisableApplicationWindows := True;
|
|
||||||
|
|
||||||
New(DisableWindowsInfo);
|
|
||||||
DisableWindowsInfo^.NewModalWindow := Window;
|
|
||||||
DisableWindowsInfo^.DisabledWindowList := TList.Create;
|
|
||||||
WindowInfo := GetWindowInfo(DisableWindowsInfo^.NewModalWindow);
|
|
||||||
WindowInfo^.DisabledWindowList := DisableWindowsInfo^.DisabledWindowList;
|
|
||||||
|
|
||||||
// EnumThreadWindows isn't available for WinCE, so we
|
|
||||||
// improvise with EnumWindows
|
|
||||||
DisableWindowsInfo^.ProcessID := GetWindowThreadProcessId(DisableWindowsInfo^.NewModalWindow, nil);
|
|
||||||
EnumWindows(@DisableWindowsProc, LPARAM(DisableWindowsInfo));
|
|
||||||
|
|
||||||
Dispose(DisableWindowsInfo);
|
|
||||||
InDisableApplicationWindows := false;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure EnableApplicationWindows(Window: HWND);
|
|
||||||
var
|
|
||||||
WindowInfo: PWindowInfo;
|
|
||||||
I: integer;
|
|
||||||
begin
|
|
||||||
WindowInfo := GetWindowInfo(Window);
|
|
||||||
if WindowInfo^.DisabledWindowList <> nil then
|
|
||||||
begin
|
|
||||||
for I := 0 to WindowInfo^.DisabledWindowList.Count - 1 do
|
|
||||||
EnableWindow(HWND(WindowInfo^.DisabledWindowList.Items[I]), true);
|
|
||||||
FreeAndNil(WindowInfo^.DisabledWindowList);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
|
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
|
||||||
var
|
var
|
||||||
textSize: Windows.SIZE;
|
textSize: Windows.SIZE;
|
||||||
|
@ -74,7 +74,6 @@ type
|
|||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
|
||||||
|
|
||||||
class procedure CloseModal(const ACustomForm: TCustomForm); override;
|
|
||||||
class procedure SetBounds(const AWinControl: TWinControl;
|
class procedure SetBounds(const AWinControl: TWinControl;
|
||||||
const ALeft, ATop, AWidth, AHeight: Integer); override;
|
const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||||
class procedure SetBorderIcons(const AForm: TCustomForm;
|
class procedure SetBorderIcons(const AForm: TCustomForm;
|
||||||
@ -339,11 +338,6 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TWinCEWSCustomForm.CloseModal(const ACustomForm: TCustomForm);
|
|
||||||
begin
|
|
||||||
EnableApplicationWindows(ACustomForm.Handle);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class procedure TWinCEWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
class procedure TWinCEWSCustomForm.SetBorderIcons(const AForm: TCustomForm;
|
||||||
const ABorderIcons: TBorderIcons);
|
const ABorderIcons: TBorderIcons);
|
||||||
begin
|
begin
|
||||||
@ -370,6 +364,8 @@ begin
|
|||||||
SizeRect.Bottom := ATop + AHeight;
|
SizeRect.Bottom := ATop + AHeight;
|
||||||
SizeRect.Right := ALeft + AWidth;
|
SizeRect.Right := ALeft + AWidth;
|
||||||
|
|
||||||
|
BorderStyle := TCustomForm(AWinControl).BorderStyle;
|
||||||
|
|
||||||
{ Verifies if the size should be overriden, acording to the ApplicationType }
|
{ Verifies if the size should be overriden, acording to the ApplicationType }
|
||||||
if (Application.ApplicationType in [atPDA, atSmartphone, atDefault]) then
|
if (Application.ApplicationType in [atPDA, atSmartphone, atDefault]) then
|
||||||
begin
|
begin
|
||||||
@ -392,7 +388,6 @@ begin
|
|||||||
{ the LCL defines the size of a form without border, winceapi with.
|
{ the LCL defines the size of a form without border, winceapi with.
|
||||||
-> adjust size according to BorderStyle
|
-> adjust size according to BorderStyle
|
||||||
Must be done after setting sizeRect }
|
Must be done after setting sizeRect }
|
||||||
BorderStyle := TCustomForm(AWinControl).BorderStyle;
|
|
||||||
Windows.AdjustWindowRectEx(@SizeRect, BorderStyleToWinAPIFlags(
|
Windows.AdjustWindowRectEx(@SizeRect, BorderStyleToWinAPIFlags(
|
||||||
BorderStyle), false, BorderStyleToWinAPIFlagsEx(TCustomForm(AWinControl), BorderStyle));
|
BorderStyle), false, BorderStyleToWinAPIFlagsEx(TCustomForm(AWinControl), BorderStyle));
|
||||||
|
|
||||||
@ -422,7 +417,6 @@ end;
|
|||||||
|
|
||||||
class procedure TWinCEWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
|
class procedure TWinCEWSCustomForm.ShowModal(const ACustomForm: TCustomForm);
|
||||||
begin
|
begin
|
||||||
DisableApplicationWindows(ACustomForm.Handle);
|
|
||||||
ShowWindow(ACustomForm.Handle, SW_SHOW);
|
ShowWindow(ACustomForm.Handle, SW_SHOW);
|
||||||
BringWindowToTop(ACustomForm.Handle);
|
BringWindowToTop(ACustomForm.Handle);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user