From 92bbf73c7851ac38c3b2707d91728e44502ea5f2 Mon Sep 17 00:00:00 2001 From: Artem Tarasov Date: Tue, 25 Jan 2022 11:54:58 +0300 Subject: [PATCH] Unregister splash window class on application exit (#48) --- SplashUnit.pas | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/SplashUnit.pas b/SplashUnit.pas index 018f23b..f4af309 100644 --- a/SplashUnit.pas +++ b/SplashUnit.pas @@ -96,14 +96,15 @@ class procedure TSplash.SetEnable(const Value: Boolean); if Value then begin EnablingFunc; - wndAtom := RegistegSplashClass(SplashWndClassName, SplashWndClass); + if wndAtom = 0 then + wndAtom := RegistegSplashClass(SplashWndClassName, SplashWndClass); + FEnable := wndAtom <> 0; end else begin FEnable := False; HideAllForm; ReleaseAllForm; DisablingFunc; - UnregistegSplashClass(SplashWndClass); end; end; @@ -142,7 +143,6 @@ class function TSplash.ConfigToMonitorCount(Config: TSplashMonitorConfig; end; end; -{$REGION 'UpdateAllForm'} class procedure TSplash.UpdateAllForm; var SplashCount: Integer; @@ -194,9 +194,7 @@ class procedure TSplash.UpdateAllForm; end; end; end; -{$ENDREGION} -{$REGION 'ShowAllForm'} class procedure TSplash.ShowAllForm; var i: Integer; @@ -210,9 +208,7 @@ class procedure TSplash.ShowAllForm; FShowing := True; uIDEvent := SetTimer(0, nIDEvent, FInterval, @TimerProc); end; -{$ENDREGION} -{$REGION 'HideAllForm'} class procedure TSplash.HideAllForm; var i: Integer; @@ -224,9 +220,7 @@ class procedure TSplash.HideAllForm; FShowing := False; end; -{$ENDREGION} -{$REGION 'ReleaseAllForm'} class procedure TSplash.ReleaseAllForm; var i: Integer; @@ -236,7 +230,6 @@ class procedure TSplash.ReleaseAllForm; SetLength(SplashWndArray, 0); end; -{$ENDREGION} class function TSplash.BuildSplashWnd(const Name: string; MonitorNum: Integer; WindowClass: TWndClassEx): HWND; @@ -246,8 +239,8 @@ class function TSplash.BuildSplashWnd(const Name: string; MonitorNum: Integer; WS_POPUP or WS_DISABLED, 0, 0, 0, 0, 0, 0, HInstance, nil); - if Result <> 0 then - SetWindowLong(Result, GWL_STYLE, NativeInt(WS_POPUP or WS_DISABLED)); + if Result <> 0 then + SetWindowLong(Result, GWL_STYLE, NativeInt(WS_POPUP or WS_DISABLED)); end; class procedure TSplash.ReleaseSplashWnd(wnd: HWND); @@ -315,7 +308,6 @@ class procedure TSplash.TimerProc(wnd: HWND; uMsg: UINT; idEvent: UINT_PTR; HideAllForm; end; -{$REGION 'PaintPicture'} class procedure TSplash.PaintPicture(wnd: HWND; MonitorNum: Integer); var Bitmap: IGPBitmap; @@ -376,7 +368,6 @@ class procedure TSplash.PaintPicture(wnd: HWND; MonitorNum: Integer); DeleteDC(BackDC); DeleteObject(hBmp); end; -{$ENDREGION} class constructor TSplash.Create; begin @@ -394,6 +385,7 @@ class procedure TSplash.PaintPicture(wnd: HWND; MonitorNum: Integer); begin Screen.Free; Enable := False; + UnregistegSplashClass(SplashWndClass); end; { TSplash.TSplashMonitorConfig }