Trying to change Windows mouse cursor icon from ja

2019-05-20 22:56发布

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:

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

1条回答
你好瞎i
2楼-- · 2019-05-20 23:31

Was there something you wanted to do that was not possible with java.awt.Cursor?

查看更多
登录 后发表回答