objective-c – 全局隐藏游标(来自后台应用程序)

objective-c – 全局隐藏游标(来自后台应用程序),第1张

概述我想隐藏状态栏应用程序中的光标,我做了一些研究.似乎这个问题的解决方案刚刚发现: Globally hide mouse cursor in Cocoa/Carbon?或http://lists.apple.com/archives/carbon-dev/2006/Jan/msg00555.html 但是引用的代码将无法编译.你们中的任何人都知道如何编译代码(通过导入一些旧的API或其他东西)或另 我想隐藏状态栏应用程序中的光标,我做了一些研究.似乎这个问题的解决方案刚刚发现:

Globally hide mouse cursor in Cocoa/Carbon?或http://lists.apple.com/archives/carbon-dev/2006/Jan/msg00555.html

但是引用的代码将无法编译.你们中的任何人都知道如何编译代码(通过导入一些旧的API或其他东西)或另一种实现这种方式(某种程度的黑客攻击)?

(我知道将光标隐藏在后台应用程序中通常是一个坏主意,但我制作的应用程序中此功能非常重要)

编辑:

这是旧的黑客,不再起作用了.

long sysvers = GetSystemVersion();// This trick doesn't work on 10.1 if (sysvers >= 0x1020){    voID CGSSetConnectionProperty(int,int,int);    int CGSCreateCString(char *);    int CGSCreateBoolean(BOol);    int _CGSDefaultConnection();    voID CGSReleaSEObj(int);    int propertyString,boolVal;    // Hack to make background cursor setting work    propertyString = CGSCreateCString("SetsCursorInBackground");    boolVal = CGSCreateBoolean(TRUE);    CGSSetConnectionProperty(_CGSDefaultConnection(),_CGSDefaultConnection(),propertyString,boolVal);    CGSReleaSEObj(propertyString);    CGSReleaSEObj(boolVal);}

它给了我4个错误:

“_CGSCreateBoolean”,引自:
– MyClass.o中的[MyClass myMethod]

“_GetSystemVersion”,引自:
– MyClass.o中的[MyClass myMethod]

“_CGSCreateCString”,引自:
– MyClass.o中的[MyClass myMethod]

“_CGSReleaSEObj”,引自:
– MyClass.o中的[MyClass myMethod]

解决方法 您需要链接到Application Services框架以消除链接器错误.

这是一个完整的Hack示例(更新为使用Core Foundation):

cat >t.c<<EOF#include <applicationservices/applicationservices.h>int main(voID){    voID CGSSetConnectionProperty(int,CFStringRef,CFBooleanRef);    int _CGSDefaultConnection();    CFStringRef propertyString;    // Hack to make background cursor setting work    propertyString = CFStringCreateWithCString(NulL,"SetsCursorInBackground",kcfStringEnCodingUTF8);    CGSSetConnectionProperty(_CGSDefaultConnection(),kcfBooleanTrue);    CFRelease(propertyString);    // HIDe the cursor and wait    CGdisplayHIDeCursor(kCGDirectMaindisplay);    pause();    return 0;}EOFgcc -framework applicationservices t.c./a.out

在Mac OS 10.5上,这会隐藏光标直到程序中断.但是,执行任何窗口服务器或停靠任务都会显示光标.

总结

以上是内存溢出为你收集整理的objective-c – 全局隐藏游标(来自后台应用程序)全部内容,希望文章能够帮你解决objective-c – 全局隐藏游标(来自后台应用程序)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1034300.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存