diff --git a/lcl/interfaces/fpgui/fpguiobject.inc b/lcl/interfaces/fpgui/fpguiobject.inc index b837e70338..debbd68004 100644 --- a/lcl/interfaces/fpgui/fpguiobject.inc +++ b/lcl/interfaces/fpgui/fpguiobject.inc @@ -92,7 +92,16 @@ end; Enter the main message loop ------------------------------------------------------------------------------} procedure TFpGuiWidgetSet.AppRun(const ALoop: TApplicationMainLoop); +var + vMainForm: TFForm; begin + { Shows the main form } + if Assigned(Application.MainForm) then + begin + vMainForm := TFPGUIPrivateWindow(Application.MainForm.Handle).Form; + vMainForm.Show; + end; + // GFApplication.EventFilter can maybe be used on X11 for aloop but it is X only GFApplication.Run; end; diff --git a/lcl/interfaces/fpgui/fpguiwsforms.pp b/lcl/interfaces/fpgui/fpguiwsforms.pp index b88d0b4951..9100c340ed 100644 --- a/lcl/interfaces/fpgui/fpguiwsforms.pp +++ b/lcl/interfaces/fpgui/fpguiwsforms.pp @@ -76,8 +76,8 @@ type public class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; - class function CreateHandle(const AWinControl: TWinControl; - const AParams: TCreateParams): TLCLIntfHandle; override; + class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override; + class procedure DestroyHandle(const AWinControl: TWinControl); override; class procedure SetFormBorderStyle(const AForm: Forms.TCustomForm; const AFormBorderStyle: TFormBorderStyle); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; @@ -132,10 +132,31 @@ class function TFpGuiWSCustomForm.CreateHandle(const AWinControl: TWinControl; var FPForm: TFPGUIPrivateWindow; begin + {$ifdef VerboseFPGUIIntf} + WriteLn('TFpGuiWSCustomForm.CreateHandle'); + {$endif} + FPForm := TFPGUIPrivateWindow.Create(AWinControl, AParams); Result := TLCLIntfHandle(FPForm); end; +{------------------------------------------------------------------------------ + Method: TFpGuiWSCustomForm.DestroyHandle + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} +class procedure TFpGuiWSCustomForm.DestroyHandle(const AWinControl: TWinControl); +var + FPForm: TFPGUIPrivateWindow; +begin + {$ifdef VerboseFPGUIIntf} + WriteLn('TFpGuiWSCustomForm.DestroyHandle'); + {$endif} + + FPForm := TFPGUIPrivateWindow(AWinControl.Handle); + FPForm.Free; +end; + {------------------------------------------------------------------------------ Method: TFpGuiWSCustomForm.GetText Params: None diff --git a/lcl/interfaces/fpgui/fpguiwsprivate.pp b/lcl/interfaces/fpgui/fpguiwsprivate.pp index a4f6af18fa..cdb6518da0 100644 --- a/lcl/interfaces/fpgui/fpguiwsprivate.pp +++ b/lcl/interfaces/fpgui/fpguiwsprivate.pp @@ -119,6 +119,7 @@ type public constructor Create(ALCLObject: TWinControl; const AParams: TCreateParams); override; procedure CreateWidget(const AParams: TCreateParams); override; + procedure DestroyWidget; override; destructor Destroy; override; function Form: TFForm; procedure SetSize(AWidth, AHeight: LongInt); override; @@ -298,21 +299,41 @@ end; { TFPGUIPrivateWindow } +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.Form + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} function TFPGUIPrivateWindow.Form: TFForm; begin Result := TFForm(Widget); end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.SetSize + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} procedure TFPGUIPrivateWindow.SetSize(AWidth, AHeight: LongInt); begin Form.Wnd.SetSize(Size(AWidth, AHeight)); end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.SetPosition + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} procedure TFPGUIPrivateWindow.SetPosition(AX, AY: Integer); begin Form.Wnd.SetPosition(Point(AX, AY)); end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.Create + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} constructor TFPGUIPrivateWindow.Create(ALCLObject: TWinControl; const AParams: TCreateParams); begin inherited Create(ALCLObject, AParams); @@ -320,25 +341,55 @@ begin Form.InsertChild(fFixed); end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.CreateWidget + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} procedure TFPGUIPrivateWindow.CreateWidget(const AParams: TCreateParams); begin - Widget := TFForm.Create(LCLObject); + Widget := TFForm.Create(nil); Form.Wnd.SetSize(Size(AParams.Width, AParams.Height)); Form.Wnd.SetPosition(Point(AParams.X, AParams.Y)); end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.DestroyWidget + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} +procedure TFPGUIPrivateWindow.DestroyWidget; +begin + Form.Free; +end; + +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.Destroy + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} destructor TFPGUIPrivateWindow.Destroy; begin inherited Destroy; end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.SetText + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} procedure TFPGUIPrivateWindow.SetText(const AText: String); begin Form.Wnd.Title := AText; end; +{------------------------------------------------------------------------------ + Method: TFPGUIPrivateWindow.GetText + Params: None + Returns: Nothing + ------------------------------------------------------------------------------} function TFPGUIPrivateWindow.GetText: String; begin Result := Form.Wnd.Title;