From ab0a39c39da6bbc37d8bc2d5dc63b4a99aa05b2e Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 31 Oct 2013 14:34:16 +0200 Subject: 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. --- src/corelib/gdi/fpg_gdi.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib/gdi') 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; -- cgit v1.2.3-70-g09d2