1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-03 10:15:38 +02:00

Close MiniBrowser correctly when the user logs off

This commit is contained in:
Salvador Díaz Fau 2021-06-14 12:58:46 +02:00
parent b5d3daf8bc
commit 3228738e3a
2 changed files with 14 additions and 1 deletions

View File

@ -256,6 +256,7 @@ type
procedure WMMoving(var aMessage : TMessage); message WM_MOVING; procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
procedure WMQueryEndSession(var aMessage: TWMQueryEndSession); message WM_QUERYENDSESSION;
public public
procedure ShowStatusText(const aText : string); procedure ShowStatusText(const aText : string);
@ -1566,6 +1567,18 @@ begin
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
end; end;
procedure TMiniBrowserFrm.WMQueryEndSession(var aMessage: TWMQueryEndSession);
begin
// We return False (0) to close the browser correctly while we can.
// This is not what Microsoft recommends doing when an application receives
// WM_QUERYENDSESSION but at least we avoid TApplication calling HALT when
// it receives WM_ENDSESSION.
// The CEF subprocesses may receive WM_QUERYENDSESSION and WM_ENDSESSION
// before the main process and they may crash before closing the main form.
aMessage.Result := 0;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TMiniBrowserFrm.Deczoom1Click(Sender: TObject); procedure TMiniBrowserFrm.Deczoom1Click(Sender: TObject);
begin begin
Chromium1.DecZoomStep; Chromium1.DecZoomStep;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 302, "InternalVersion" : 303,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "91.1.16.0" "Version" : "91.1.16.0"
} }