diff --git a/packages/delphi11/heidisql.dpr b/packages/delphi11/heidisql.dpr index 54b684d1..057d2d77 100644 --- a/packages/delphi11/heidisql.dpr +++ b/packages/delphi11/heidisql.dpr @@ -52,6 +52,7 @@ begin Application.Title := APPNAME; Application.UpdateFormatSettings := False; Application.CreateForm(TMainForm, MainForm); + Application.OnMessage := Mainform.OnMessageHandler; debug('perf: Main created.'); try diff --git a/source/connections.pas b/source/connections.pas index 89032a6b..589f2222 100644 --- a/source/connections.pas +++ b/source/connections.pas @@ -116,6 +116,7 @@ end; procedure Tconnform.FormCreate(Sender: TObject); var LastSession: String; + hSysMenu: THandle; begin // Fix GUI stuff InheritFont(Font); @@ -131,6 +132,11 @@ begin LastSession := GetRegValue(REGNAME_LASTSESSION, ''); SelectNode(ListSessions, FSessionNames.IndexOf(LastSession)); ValidateControls; + // Add own menu items to system menu + hSysMenu := GetSystemMenu(Handle, False); + AppendMenu(hSysMenu, MF_SEPARATOR, 0, #0); + AppendMenu(hSysMenu, MF_STRING, MSG_UPDATECHECK, PAnsiChar(Mainform.actUpdateCheck.Caption)); + AppendMenu(hSysMenu, MF_STRING, MSG_ABOUT, PAnsiChar(Mainform.actAboutBox.Caption)); end; diff --git a/source/main.pas b/source/main.pas index 555f81cf..bbdf521e 100644 --- a/source/main.pas +++ b/source/main.pas @@ -33,6 +33,8 @@ const // number of seen (or simulated) rows the scrollbar should project. SIMULATE_INITIAL_ROWS = 10000; SIMULATE_MORE_ROWS = 20; + MSG_UPDATECHECK = WM_USER + 1; + MSG_ABOUT = WM_USER + 2; type TMainForm = class(TForm) @@ -876,6 +878,7 @@ type procedure SetEditorTabCaption(Editor: TFrame; ObjName: WideString); procedure ResetSelectedTableStuff; procedure SetWindowCaption; + procedure OnMessageHandler(var Msg: TMsg; var Handled: Boolean); end; @@ -9439,5 +9442,18 @@ begin end; +procedure TMainForm.OnMessageHandler(var Msg: TMsg; var Handled: Boolean); +begin + // Clicks on system window menu get handled here + if Msg.message = WM_SYSCOMMAND then begin + case Msg.wParam of + MSG_UPDATECHECK: Mainform.actUpdateCheck.Execute; + MSG_ABOUT: Mainform.actAboutBox.Execute; + end; + Handled := True; + end; +end; + + end.