我想从状态栏应用程序中隐藏光标,并且我已经做了一些研究。似乎不久前就找到了这个问题的解决方案:
在 Cocoa/Carbon 中全局隐藏鼠标光标? or http://lists.apple.com/archives/carbon-dev/2006/Jan/msg00555.html
但所引用的代码将无法编译。你们中有人知道如何编译代码(通过导入一些旧的 API 或其他东西)或实现此目标的其他方法(某种 hack)吗?
(我知道从后台应用程序中隐藏光标通常是一个坏主意,但我制作了一个应用程序,其中此功能非常重要)
Edit:
这是旧的黑客,不再起作用了。
long sysVers = GetSystemVersion();
// This trick doesn't work on 10.1
if (sysVers >= 0x1020)
{
void CGSSetConnectionProperty(int, 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]