SilverScreen Solid Modeler

Changing the Mouser Cursor Shape

Changing the Mouser Cursor Shape

Previous topic Next topic  

Changing the Mouser Cursor Shape

Previous topic Next topic JavaScript is required for the print function  

SilverPlusEllipse

 

Changing the Mouser Cursor Shape

 


In a DLL, there are two ways that you can change the shape of the mouse cursor. One way is to set the view window's class cursor to the handle of the cursor you want to use. The other is to set the view window's class cursor field to NULL, and trap the WM_MOUSEMOVE command in your subclassing window procedure, and calling SetCursor with the handle of your desired cursor there.

 

 


The following is an example of the first approach:

 

C / C++ Code

 

. . .

 

static HCURSOR view_cursor = 0;

extern HINSTANCE dll_instance;

 

void SetMouseCursor()

  {

  HWND hwnd;

 

  if ( hwnd = GetViewHwnd() )

     {

     HCURSOR cursor = LoadCursor(dll_instance,

                                 MAKEINTRESOURCE(IDC_DLLCURSOR));

 

     view_cursor = (HCURSOR)SetClassLong(hwnd,

                                         GCL_HCURSOR,

                                         (DWORD) NewCursor);

 }

  }

 

 

 


The following is an example of the second approach. First, set the view window's class cursor to NULL:

 

C / C++ Code

 

. . .

 

static HCURSOR   view_cursor = 0;

extern HINSTANCE dll_instance;

 

void SetMouseCursor()

  {

  HWND hwnd;

 

  if ( hwnd = GetViewHwnd() )

     {

     view_cursor = (HCURSOR) SetClassLong(hwnd,

                                          GCL_HCURSOR,

                                          (DWORD) NULL);

  }

  }

 

 

Then, in the subclassing window procedure:

 

C / C++ Code

 

static HCURSOR myCursor = 0;

extern HINSTANCE dll_instance;

 

 

switch ( message )

  {

  . . .

 

  case WM_MOUSEMOVE:                                

 

       if ( ! myCursor )

          myCursor = LoadCursor(dll_instance,

                                MAKEINTRESOURCE(IDC_DLLCURSOR));

 

       SetCursor( myCursor );

       break;

 

  . . .

  }

   

 

 

You must remember that if you change the view window's class cursor, you must restore the original  before returning to SilverScreen, otherwise the cursor will be left with an invalid resource id (one that references an unloaded DLL).