Custom mouse pointer handling?

BlitzMax Forums/BlitzMax Programming/Custom mouse pointer handling?

I am trying to figure out how to implement a routine that handles a custom mouse pointer onscreen, which of course follows the mouse and updates nice and responsively.

Obviously the first thing you'd do is hide the default mouse pointer. And you can then read the mouse coordinates. And you could then draw an image at the mouse coordinates and flip the screen to see it. So long as the app runs at enough frames-per-second it should show the custom mouse flying around.

Well, okay, easy enough. But how would you get this custom mouse pointer to do the same thing, if

a) your main app does not run at a high framerate but you still want a fast and responsive mouse
b) you haven't got hardware interrupts in BlitzMax
c) you want the mouse to update at a fixed framerate
d) you only want to update the mouse-pointer graphic without having to do a whole entire `Flip` just to see the pointer

????????

Anyone?

You can't render faster than your game is rendering ... otherwise you wouldn't be in the position that you're in.

There's no way to have a hardware cursor without just using the hardware cursor. Which, really, isn't the worst idea ever. A responsive mouse cursor will make any UI seem more responsive.

Is there perhaps a way to change the system's hardware cursor to a different image from within BlitzMax?

Here is a C example how to load your own cursors

just Import the c file and make the Extern things to
call the functions. ( and change the c source to
load your own cursor pics )


#include <windows.h>

#define    CUR_DEFAULT     0
#define    CUR_RESIZE      1
#define    CUR_DRAW        2
#define    CUR_LINE        3
#define    CUR_POLY        4
#define    CUR_RECT        5
#define    CUR_CIRCLE      6
#define    CUR_SPRAY       7
#define    CUR_FILL        8
#define    CUR_GETBRUSH    9
#define    CUR_TEXT        10
#define    CUR_ZOOM        11
#define    CUR_GETCOLOR    12
#define    CUR_WAIT        13

HCURSOR g_cur[15];
HWND g_cur_hwnd;
unsigned int g_cur_class;

/*========================================================================
   
 ========================================================================*/
void CursorLoad ( HWND hwnd )
{
   g_cur_hwnd = hwnd;
   g_cur[CUR_DEFAULT] = LoadCursor (0, IDC_ARROW );
   g_cur[CUR_RESIZE] = LoadCursor (0, IDC_SIZE );
   g_cur[CUR_DRAW] = LoadCursorFromFile ( "default.cur" );
   g_cur[CUR_LINE] = LoadCursorFromFile ( "line.cur" );
   g_cur[CUR_POLY] = LoadCursorFromFile ( "poly.cur" );
   g_cur[CUR_RECT] = LoadCursorFromFile ( "rect.cur" );
   g_cur[CUR_CIRCLE] = LoadCursorFromFile ( "circle.cur" );
   g_cur[CUR_SPRAY] = LoadCursorFromFile ( "spray.cur" );
   g_cur[CUR_FILL] = LoadCursorFromFile ( "fill.cur" );
   g_cur[CUR_GETBRUSH] = LoadCursorFromFile ( "getbrush.cur" );
   g_cur[CUR_TEXT] = LoadCursorFromFile ( "text.cur" );
   g_cur[CUR_ZOOM] = LoadCursorFromFile ( "zoom.cur" );
   g_cur[CUR_GETCOLOR] = LoadCursorFromFile ( "getcolor.cur" );
   g_cur[CUR_WAIT] = LoadCursorFromFile ( "wait.ani" );

   g_cur_class = GetClassLong ( g_cur_hwnd, GCL_HCURSOR );
   SetClassLong ( g_cur_hwnd, GCL_HCURSOR, 0 );
}


/*========================================================================
   
 ========================================================================*/
void CursorSet ( int cnum )
{
   SetCursor ( g_cur[cnum] );
}


/*========================================================================
   
 ========================================================================*/
void CursorShutdown ( void )
{
   int loop;

   SetClassLong ( g_cur_hwnd, GCL_HCURSOR, g_cur_class );

   for (loop = 0; loop < 12; loop++ ) 
   {
       DestroyCursor ( g_cur[loop] );
   }
}




















Hmm ok thanks. I don't know C very well at all but I expect someone will find it useful.