KH0RKHE Posted March 24, 2021 Share Posted March 24, 2021 I have a VCL application, which can start and shutdown various servers. One of those servers would eventually be a uniGUI server module. the files generated by the uniGUI standalone application wizard were copied into my VCL application: I am able to launch the uniGUI server, at which point the uniGUI tray icon appears, and test the default page in a web browser. Shutting down the server's listener (using FUniServerModule.Active := False), I can verify that the browser no longer loads the page, yet the tray icon remains. Following the suggestion by Tim posted in the link below, it is possible to disable this tray icon *only if* the TServerModule is the Application's main form. This is not the case for me, so how can I control the visibility of the tray icon, given that the uniGUI server's lifetime is managed by my application? Edit: this could possibly be solved if i can get a handle to the TServerModule's form. Thanks! Quote Link to comment Share on other sites More sharing options...
KH0RKHE Posted March 24, 2021 Author Share Posted March 24, 2021 ended up finding a solution that builds on top of the answer in the link. at the moment of launching a uniGUI server, I will have 2 forms created: the Main form and the uniGUI server form. All that's needed is to pick the one that is not the main form. Obviously, if others may have a different situation, the condition to find the "correct" form can simply be adapted. procedure TUniServerModuleTemplate.UniGUIServerModuleCreate(Sender: TObject); var NotifyIconData : TNotifyIconData; vForm: TForm; iForm: Integer; begin for iForm := 0 to Screen.FormCount - 1 do begin vForm := Screen.Forms[iForm]; if vForm.Handle <> Application.MainForm.Handle then break; end; FillChar( NotifyIconData, System.SizeOf(TNotifyIconData), 0 ); NotifyIconData.cbSize := SizeOf(TNotifyIconData); NotifyIconData.Wnd := vForm.Handle; NotifyIconData.uID := 1002; Shell_NotifyIcon( NIM_DELETE, @NotifyIconData ) end; Quote Link to comment Share on other sites More sharing options...
andyhill Posted March 25, 2021 Share Posted March 25, 2021 I would suggest that instead of making a StandAlone EXE project, create it as a Windows Service where one can stop / start it at will (Net stop servicename). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.