tags:

views:

136

answers:

3

Working on a service application in Delphi 5 that is intended to run on Windows XP - 7. Most of the application is coming together nicely, but I'm running into one issue. Part of this service application is a form that displays data occasionally (similar to the slider box Avast uses to let you know its updated). When the service shows the form, the form displays on the taskbar, but we don't want it to. Does anyone have any suggestions as to how to hide the form's button on the taksbar? None of the standard methods I've found for regular applications have worked so far. Thanks.

+1  A: 

Found this on http://delphi.about.com/od/adptips1999/qt/hidefromtaskbar.htm

procedure TMainForm.FormCreate(Sender: TObject) ;
begin
  ShowWindow(Application.Handle, SW_HIDE) ;
  SetWindowLong(Application.Handle, GWL_EXSTYLE, getWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW) ;
  ShowWindow(Application.Handle, SW_SHOW) ;
end;

With Delphi 2007, to hide the taskbar button you'll need a few code lines:

Set MainFormOnTaskBar to FALSE

Inside the main form's OnShow event handler call

ShowWindow(Application.Handle, SW_HIDE);

Inside the main form's OnActivate event handler call

ShowWindow(Application.Handle, SW_HIDE); 
Zartog
Yeah, I found this too, but it didn't work, unfortunately, since it is aimed at winforms applications, not service applications (different application variable type). Thanks though.
Tom
+7  A: 

It sounds as if you envisage having a notification area icon (a.k.a. system tray icon) to inform the user about events in/relating to the service.

You need to separate this GUI aspect of your service from the service itself and use some sort of IPC to allow the tray icon applet to communicate with the service as required. Depending on the needs of your IPC this could be a named pipe, shared access to a memory mapped file or something more sophisticated.

Then the techniques for managing the behaviour of the GUI w.r.t the taskbar should work as expected.

Deltics
+1  A: 

Override the form's CreateParams method and add the WS_EX_TOOLWINDOW value to the Params.ExStyle field. That will flag it as a tool window, which won't have a taskbar entry.

Craig Peterson
Works great now. Thanks.
Tom