views:

147

answers:

1

Is it possible to hide dock icon programmatically on demand. I know one way by which defining property "Application is agent (UIElement)" in plist we make the cocoa app as user agent. But this result in hiding the dock icon permanently.

I am looking for a way where i can control visibility of dock icon. Any idea ?

+2  A: 

Unfortunately not. You can transform a background-only app to a foreground app using the TransformProcessType() function but you can't go from a foreground app to a background app.

Here's how to go from background to foreground:

ProcessSerialNumber psn = { 0, kCurrentProcess }; 
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
if( returnCode != 0) {
    NSLog(@"Could not bring the application to front. Error %d", returnCode);
}
Rob Keniger
Ohh..is it possible to control visibility of main menu programmatically ? If i can do that then i might have solution. ?
Unicorn
Unicorn: It is on Mac OS X 10.6: http://developer.apple.com/mac/library/technotes/KioskMode/ On older versions of Mac OS X, you can use `SetSystemUIMode` with the `kUIModeAllHidden` option, as described in TN2062: http://developer.apple.com/mac/library/technotes/tn2002/tn2062.html but that solution will also hide the Dock (not just your Dock tile—*the whole Dock*).
Peter Hosey
Yes I tried that, but its not what I need. If this is technical limitation then i shld figure some other way out... Thanks for ur help guys !
Unicorn