diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-10-31 14:34:16 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-10-31 14:34:16 +0200 |
commit | ab0a39c39da6bbc37d8bc2d5dc63b4a99aa05b2e (patch) | |
tree | f50a5e977208d432f765454190e8bb914288291a /src/corelib/gdi | |
parent | db6eeeb7b69bdca3f8d2fda0f3967c711efd1123 (diff) | |
download | fpGUI-ab0a39c39da6bbc37d8bc2d5dc63b4a99aa05b2e.tar.xz |
gdi: prevents an AV if applications have a non-standard startup
I sometimes implement a "-h" help command line parameter to GUI and non-GUI
applications. For GUI applications it pops up a dialog that displays help
then quits before the main form displays. Without the change in this
commit, the GUI applications will trigger an AV, because MainForm = nil in
the code referenced in this commit.
Diffstat (limited to 'src/corelib/gdi')
-rw-r--r-- | src/corelib/gdi/fpg_gdi.pas | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/gdi/fpg_gdi.pas b/src/corelib/gdi/fpg_gdi.pas index 74787683..1db80a76 100644 --- a/src/corelib/gdi/fpg_gdi.pas +++ b/src/corelib/gdi/fpg_gdi.pas @@ -1249,6 +1249,8 @@ begin end; function TfpgGDIApplication.GetHiddenWindow: HWND; +var + lHandle: TfpgWinHandle; begin if (FHiddenWindow = 0) then begin @@ -1264,8 +1266,12 @@ begin end; Windows.RegisterClass(@HiddenWndClass); + if MainForm <> nil then + lHandle := TfpgGDIWindow(MainForm).FWinHandle + else + lHandle := -1; FHiddenWindow := CreateWindow('FPGHIDDEN', '', - DWORD(WS_POPUP), 0, 0, 0, 0, TfpgGDIWindow(MainForm).FWinHandle, 0, MainInstance, nil); + DWORD(WS_POPUP), 0, 0, 0, 0, lHandle, 0, MainInstance, nil); end; Result := FHiddenWindow; end; |