diff options
-rw-r--r-- | examples/gui/filedialog/filedialog.lpi | 2 | ||||
-rw-r--r-- | examples/gui/filedialog/filedialog.lpr | 2 | ||||
-rw-r--r-- | examples/gui/modalforms/modalforms.lpi | 2 | ||||
-rw-r--r-- | examples/gui/modalforms/modalforms.lpr | 5 | ||||
-rw-r--r-- | src/corelib/fpg_main.pas | 11 | ||||
-rw-r--r-- | src/corelib/fpg_widget.pas | 2 | ||||
-rw-r--r-- | src/corelib/x11/fpg_x11.pas | 10 | ||||
-rw-r--r-- | src/gui/fpg_dialogs.pas | 2 | ||||
-rw-r--r-- | src/gui/fpg_form.pas | 2 | ||||
-rw-r--r-- | src/gui/fpg_menu.pas | 1 |
10 files changed, 26 insertions, 13 deletions
diff --git a/examples/gui/filedialog/filedialog.lpi b/examples/gui/filedialog/filedialog.lpi index 872cf6e3..f6efbd83 100644 --- a/examples/gui/filedialog/filedialog.lpi +++ b/examples/gui/filedialog/filedialog.lpi @@ -36,7 +36,6 @@ <Unit0> <Filename Value="filedialog.lpr"/> <IsPartOfProject Value="True"/> - <UnitName Value="filedialog"/> </Unit0> </Units> </ProjectOptions> @@ -54,6 +53,7 @@ </SyntaxOptions> </Parsing> <Other> + <CustomOptions Value="-FUunits"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/filedialog/filedialog.lpr b/examples/gui/filedialog/filedialog.lpr index 315b7885..1294ac06 100644 --- a/examples/gui/filedialog/filedialog.lpr +++ b/examples/gui/filedialog/filedialog.lpr @@ -119,7 +119,7 @@ procedure TMainForm.btnOpenFileClick(Sender: TObject); var dlg: TfpgFileDialog; begin - dlg := TfpgFileDialog.Create(nil); + dlg := TfpgFileDialog.Create(Self); try // defines 3 filters (All Files, Object Pascal and Lazarus Project) dlg.Filter := 'All Files (*)|*|Object Pascal (*.pas;*.lpr;*.pp)|*.pas;*.lpr;*.pp|Lazarus Project (*.lpi)|*.lpi'; diff --git a/examples/gui/modalforms/modalforms.lpi b/examples/gui/modalforms/modalforms.lpi index cc8137c8..2f25e23a 100644 --- a/examples/gui/modalforms/modalforms.lpi +++ b/examples/gui/modalforms/modalforms.lpi @@ -36,7 +36,6 @@ <Unit0> <Filename Value="modalforms.lpr"/> <IsPartOfProject Value="True"/> - <UnitName Value="modalforms"/> </Unit0> </Units> </ProjectOptions> @@ -54,6 +53,7 @@ </SyntaxOptions> </Parsing> <Other> + <CustomOptions Value="-FUunits"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/modalforms/modalforms.lpr b/examples/gui/modalforms/modalforms.lpr index 99f53ab3..bac0af81 100644 --- a/examples/gui/modalforms/modalforms.lpr +++ b/examples/gui/modalforms/modalforms.lpr @@ -99,7 +99,7 @@ procedure TForm1.btnOpenForm2Click(Sender: TObject); var frm: TForm2; begin - frm := TForm2.Create(nil); + frm := TForm2.Create(Self); try frm.ShowModal; writeln('Form2: This should only appear after the form closes.'); @@ -113,6 +113,7 @@ end; constructor TForm1.Create(AOwner: TComponent); begin inherited Create(AOwner); + Visible:=False; WindowTitle := 'Form1'; Sizeable := False; SetPosition(150, 150, 200, 200); @@ -144,7 +145,7 @@ procedure TMainForm.btnOpenForm1Click(Sender: TObject); var frm: TForm1; begin - frm := TForm1.Create(nil); + frm := TForm1.Create(Self); try frm.ShowModal; writeln('Form1: This should only appear after the form closes.'); diff --git a/src/corelib/fpg_main.pas b/src/corelib/fpg_main.pas index 3bdb43e2..d74a9be4 100644 --- a/src/corelib/fpg_main.pas +++ b/src/corelib/fpg_main.pas @@ -2029,10 +2029,13 @@ begin FModalForWin := nil; - if (AOwner <> nil) and (AOwner is TfpgWindow) then - FWindowType := wtChild - else - FWindowType := wtWindow; + if not (FWindowType in [wtModalForm, wtPopup]) then + begin + if (AOwner <> nil) and (AOwner is TfpgWindow) then + FWindowType := wtChild + else + FWindowType := wtWindow; + end; FCanvas := CreateCanvas; end; diff --git a/src/corelib/fpg_widget.pas b/src/corelib/fpg_widget.pas index 3212e75c..150a8284 100644 --- a/src/corelib/fpg_widget.pas +++ b/src/corelib/fpg_widget.pas @@ -507,7 +507,7 @@ begin inherited Create(AOwner); - if (AOwner <> nil) and (AOwner is TfpgWidget) then + if (AOwner <> nil) and (AOwner is TfpgWidget) and (not (WindowType in [wtModalForm, wtPopup])) {and not InheritsFrom(TfpgForm)} then begin Parent := TfpgWidget(AOwner); FTabOrder := AOwner.ComponentCount; diff --git a/src/corelib/x11/fpg_x11.pas b/src/corelib/x11/fpg_x11.pas index 54908c0f..381b81a3 100644 --- a/src/corelib/x11/fpg_x11.pas +++ b/src/corelib/x11/fpg_x11.pas @@ -2355,11 +2355,13 @@ var WMHints: PXWMHints; prop: TAtom; mwmhints: TMWMHints; + IsToplevel: Boolean; begin if HandleIsValid then Exit; //==> - if AParent <> nil then + IsToplevel := (AParent = nil) or (FWindowType in [wtModalForm, wtPopup]); + if not IsToplevel then pwh := TfpgX11Window(AParent).WinHandle else pwh := xapplication.RootWindow; @@ -2398,7 +2400,7 @@ begin FWinHandle := wh; FBackupWinHandle := wh; - if AParent = nil then // is a toplevel window + if IsToplevel then // is a toplevel window begin { setup a window icon } @@ -2494,11 +2496,13 @@ begin // for modal windows, this is necessary if FWindowType = wtModalForm then begin - if Parent = nil then + if IsToplevel then begin lmwh := 0; if fpgApplication.PrevModalForm <> nil then lmwh := TfpgX11Window(fpgApplication.PrevModalForm).WinHandle + {else if AParent <> nil then + lmwh := TfpgX11Window(AParent).WinHandle} { 2011-03-24: Graeme Geldenhuys I commented code this code because it caused more problems that it solved when multiple modal dialogs or prompts are shown in succession. diff --git a/src/gui/fpg_dialogs.pas b/src/gui/fpg_dialogs.pas index 781c0745..7cb1ee20 100644 --- a/src/gui/fpg_dialogs.pas +++ b/src/gui/fpg_dialogs.pas @@ -579,6 +579,8 @@ end; constructor TfpgBaseDialog.Create(AOwner: TComponent); begin + // WindowType must be set before inherited or our parent property will be set + WindowType:=wtModalForm; inherited Create(AOwner); Width := 500; Height := 400; diff --git a/src/gui/fpg_form.pas b/src/gui/fpg_form.pas index af76de2a..3f1f2558 100644 --- a/src/gui/fpg_form.pas +++ b/src/gui/fpg_form.pas @@ -345,6 +345,8 @@ function TfpgBaseForm.ShowModal: TfpgModalResult; var lCloseAction: TCloseAction; begin + if HasHandle and (FWindowType <> wtModalForm) then + HandleHide; FWindowType := wtModalForm; fpgApplication.PushModalForm(self); ModalResult := mrNone; diff --git a/src/gui/fpg_menu.pas b/src/gui/fpg_menu.pas index 3f634c02..7b93be06 100644 --- a/src/gui/fpg_menu.pas +++ b/src/gui/fpg_menu.pas @@ -1342,6 +1342,7 @@ end; constructor TfpgPopupMenu.Create(AOwner: TComponent); begin + FWindowType:=wtPopup; inherited Create(AOwner); FMargin := 3; FTextMargin := 3; |