我想從狀態欄應用程序隱藏光標,我已經做了一些研究。它好像解決這個問題前一段時間發現:全局隱藏光標(從後臺應用程序)
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);
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
「_GetSystemVersion」,從引用[MyClass的myMethod的]: - [MyClass的myMethod的[MyClass的myMethod的]在MyClass.o
- :]在MyClass.o「_CGSCreateCString」,從參考
「_CGSReleaseObj」,從引用: - 在MyClass.o
請編輯您的問題,以包括您使用的確切代碼和您得到的錯誤。 – 2010-10-07 22:28:35