尝试通过 jni 调用从 java 更改 Windows 鼠标光标图标
在我的java应用程序中,我尝试使用具有透明度的argb 32位bmp文件更改鼠标光标。
我想进行 jni 调用以从 Windows 更改它,因为在 java 中更改光标会给我一个非常糟糕的鼠标光标(所有透明度都是 0x00 或 0xFF)
目前我正在尝试使用函数 SetClassLong 作为参数:
- 来自java的hWnd(我按照该方法得到它 http:// /download.oracle.com/javase/1.3/docs/guide/awt/AWT_Native_Interface.html )
- GCL_HCURSOR
- 和由原始 argb 32 位 bmp 缓冲区制成的光标
该代码段在示例 win32 atl windows 测试程序中工作:
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);
但不是在通过 jni 从 java 调用的 dll 中
如果有人对这种情况有更好的方法或解决方案,谢谢
干杯
In my java application, i m trying to change the mouse cursor with an argb 32bit bmp file with transparency.
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)
At the moment i'm trying to use the function SetClassLong with as parameters:
- 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
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);
But not in a dll called from java through jni
If somebody has a better approach or solution to this case, thanks
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论