尝试通过jni调用从java更改Windows鼠标光标图标 [英] Trying to change Windows mouse cursor icon from java through jni call
问题描述
在我的java应用程序,我试图改变鼠标光标与一个透明的argb 32位bmp文件。
In my java application, i m trying to change the mouse cursor with an argb 32bit bmp file with transparency.
我想做一个jni调用来改变它Windows因为改变java中的游标给我一个非常糟糕的鼠标光标(所有的透明度是0x00或0xFF)
I want to make a jni call to change it from Windows because changing the cursor in java gives me a really bad mouse cursor (all the transparency is either 0x00 or 0xFF)
目前我试图使用函数SetClassLong作为参数:
At the moment i'm trying to use the function SetClassLong with as parameters:
- 来自java的hWnd(我得到它的方法 http://download.oracle.com/javase/1.3/docs/guide/awt/AWT_Native_Interface.html )
- GCL_HCURSOR
- 和由原始argb 32位bmp缓冲区建立的游标
- the hWnd from java (i got it following that method http://download.oracle.com/javase/1.3/docs/guide/awt/AWT_Native_Interface.html )
- GCL_HCURSOR
- and a cursor made from a raw argb 32bit bmp buffer
这段代码在一个示例win32 atl windows测试程序中工作:
That piece of code works in a sample win32 atl windows test program:
HBITMAP hBitmap = (HBITMAP)CreateBitmap(32, 32, 1, 32, pRawBmpData);
BITMAP bmp;
::GetObject(hBitmap, sizeof(BITMAP), &bmp);
HBITMAP hMask = ::CreateCompatibleBitmap(::GetDC(NULL), bmp.bmWidth, bmp.bmHeight);
ICONINFO ii = {0};
ii.fIcon = FALSE;
ii.hbmColor = hBitmap;
ii.hbmMask = hMask;
ii.xHotspot = 0;
ii.yHotspot = 0;
HCURSOR cursor = ::CreateIconIndirect(&ii);
SetCursor(cursor);
SetClassLong(hWnd, GCL_HCURSOR, (DWORD)cursor);
但不是从java到jni调用的dll
But not in a dll called from java through jni
如果有人有更好的方法或解决方案,感谢
If somebody has a better approach or solution to this case, thanks
干杯
推荐答案
有什么你想做的是不可能的 java.awt.Cursor ?
Was there something you wanted to do that was not possible with java.awt.Cursor?
这篇关于尝试通过jni调用从java更改Windows鼠标光标图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!