I have an app that's shown as a Menu on the Status Bar, so I switched the "Application is agent (UIElement)" in plist to YES (because I dont want an icon on the dock just for a Menu on the Status Bar), but when I click an Item on the Menu a new window is called, is it possible to make a dock icon appear for that window? and disappear when the window is closed?
Asked
Active
Viewed 734 times
3 Answers
1
You can show and hide the Dock icon of an application with NSRunningApplication+DockIcon but beware, this code uses undocumented APIs.

0xced
- 25,219
- 10
- 103
- 255
1
To set your application to be a foreground application, which causes its icon to appear in the Dock, and the app to appear in the Cmd+Tab list:
ProcessSerialNumber processSerialNumber = {0, kCurrentProcess};
TransformProcessType(&processSerialNumber, kProcessTransformToForegroundApplication);
And to change it back again:
ProcessSerialNumber processSerialNumber = {0, kCurrentProcess};
TransformProcessType(&processSerialNumber, kProcessTransformToUIElementApplication);

Jon Schneider
- 25,758
- 23
- 142
- 170
1
You will need to create a separate application binary/bundle to display that window. There is no supported way for an application to cause a Dock icon to be displayed on anything other than a per-process basis, or to dynamically hide/show the Dock icon while it's running.
-
Thanks for the answer, but then can I call that new app from my MenuItems? how can I do that? – Crackoder Sep 28 '11 at 06:02
-
Sure. Just put it inside your "main" application's bundle, then launch it when it's needed. – Sep 28 '11 at 06:33