Jump to content
uniGUI Discussion Forums
Tim

How to hide Windows tray icon?

Recommended Posts

When a UniGui project is compiled and run as Standalone Server, a square purple icon appears in the Windows system tray:

TrayIcon.png.4ce922e5d1e4b582ed87aa1bb5478795.png

Is there any way to prevent this icon appearing?

Share this post


Link to post
Share on other sites

Hello,

And how will you stop the application,  or do you mean debug mode ?!

 

Share this post


Link to post
Share on other sites

Hello,

thanks for the reply. It will be started and stopped automatically by another Delphi executable.

Tim

Share this post


Link to post
Share on other sites

Still looking for a solution to this...

Is there some simple way for a UniGui application to obtain the handle to its own Windows tray icon? Then i might be able to close it using Shell_NotifyIcon(NIM_DELETE...) 

Any other suggestions?

Share this post


Link to post
Share on other sites

Our unigui app is a portal app for logging and controlling a non visual delphi program. The delphi program starts the unigui portal when itself starts and close it when itself closes. The portal app should not show any tray icon. It should run silently in background and serve the portal website for the non visual delphi program (http://localhost:8080). Running the unigui app as a service is no option. We are not allowed to install it as a service.

It would be nice if we could set a property "ShowTrayIcon" in ServerModule.

Share this post


Link to post
Share on other sites

I was able to hide the Windows tray icon after startup by adding the following code to ServerModule:

 

uses
  ShellAPI,
  Forms,

...

procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
var
  NotifyIconData : TNotifyIconData;
begin
  FillChar( NotifyIconData, System.SizeOf(TNotifyIconData), 0 );
  NotifyIconData.cbSize := SizeOf(TNotifyIconData);
  NotifyIconData.Wnd := Application.MainForm.Handle;
  NotifyIconData.uID := 1002;
  Shell_NotifyIcon( NIM_DELETE, @NotifyIconData );
end;

 

Does this seem like a valid approach? It works fine in my tests so far (using v1.50.0.1481 on Windows 10).

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×