开发者

Service Application too visible

开发者 https://www.devze.com 2022-12-26 05:24 出处:网络
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 applicati

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 met开发者_JAVA技巧hods I've found for regular applications have worked so far. Thanks.


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.


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.


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); 
0

精彩评论

暂无评论...
验证码 换一张
取 消