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
Was there something you wanted to do that was not possible with java.awt.Cursor?