Jump to content

integrating a uniGUI server into a VCL application, tray icon visibility


KH0RKHE

Recommended Posts

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!

 

 

 

 

Link to comment
Share on other sites

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;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...