问题描述
可以根据需要以程序方式隐藏停靠站图标。我知道一种方式通过其中定义属性应用程序是代理(UIElement)在plist中,我们使可可应用程序作为用户代理。但这个结果永久隐藏了dock图标。
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.
我正在寻找一种方法,我可以控制dock图标的可见性。任何想法 ?
I am looking for a way where i can control visibility of dock icon. Any idea ?
推荐答案
不幸的是。您可以使用 TransformProcessType()
函数将仅限后台应用程序转换为前台应用程序,但不能从前台应用程序转到后台应用程序。
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.
如何从后台到前台:
ProcessSerialNumber psn = { 0, kCurrentProcess };
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
if( returnCode != 0) {
NSLog(@"Could not bring the application to front. Error %d", returnCode);
}
这篇关于是否可以通过编程方式隐藏dock图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!