Skip to content

Commit

Permalink
Unregister splash window class on application exit (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
artar94 committed Jan 25, 2022
1 parent 2431f3a commit 92bbf73
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions SplashUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -142,7 +143,6 @@ class function TSplash.ConfigToMonitorCount(Config: TSplashMonitorConfig;
end;
end;

{$REGION 'UpdateAllForm'}
class procedure TSplash.UpdateAllForm;
var
SplashCount: Integer;
Expand Down Expand Up @@ -194,9 +194,7 @@ class procedure TSplash.UpdateAllForm;
end;
end;
end;
{$ENDREGION}

{$REGION 'ShowAllForm'}
class procedure TSplash.ShowAllForm;
var
i: Integer;
Expand All @@ -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;
Expand All @@ -224,9 +220,7 @@ class procedure TSplash.HideAllForm;

FShowing := False;
end;
{$ENDREGION}

{$REGION 'ReleaseAllForm'}
class procedure TSplash.ReleaseAllForm;
var
i: Integer;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -376,7 +368,6 @@ class procedure TSplash.PaintPicture(wnd: HWND; MonitorNum: Integer);
DeleteDC(BackDC);
DeleteObject(hBmp);
end;
{$ENDREGION}

class constructor TSplash.Create;
begin
Expand All @@ -394,6 +385,7 @@ class procedure TSplash.PaintPicture(wnd: HWND; MonitorNum: Integer);
begin
Screen.Free;
Enable := False;
UnregistegSplashClass(SplashWndClass);
end;

{ TSplash.TSplashMonitorConfig }
Expand Down

0 comments on commit 92bbf73

Please sign in to comment.