Setting the Wait Cursor type using ObjectARX and Win32

by Fenton Webb

Sometimes, you want to tell the user that your application is busy and what better way to do that then with an Hour Glass wait cursor… Obviously, you can create your own custom cursor and display it using the same technique…

Here’s how:

//////////////////////////////////////////////////////////////////////////

static HHOOK MyHook;

static HCURSOR hWaitCursor;

//////////////////////////////////////////////////////////////////////////

static LRESULT CALLBACK MyMsgProc (int nCode, WPARAM wParam, LPARAM lParam);

//////////////////////////////////////////////////////////////////////////

// This is command ‘WAITCURSOR, by Fenton Webb [14/10/2004], DevTech, Autodesk

void asdkWaitCursor()

{

  // load the Wait cursor

  hWaitCursor = LoadCursor(NULL, IDC_WAIT);  

  // and set it

  HCURSOR hCursor = SetCursor(hWaitCursor); 

 

  // now set a hook so we can constantly keep our cursor set

  MyHook = SetWindowsHookEx(WH_CALLWNDPROCRET, (HOOKPROC)MyMsgProc, (HINSTANCE)

 NULL, GetCurrentThreadId ()); 

  // now do the wait intensive task…

  ACHAR cResult [256];

  acedGetString (0, _T("\nPretending to wait : "), cResult); 

 

  // and finally clean up

  UnhookWindowsHookEx (MyHook) ;

 

  SetCursor (hCursor) ;

}

//////////////////////////////////////////////////////////////////////////

LRESULT CALLBACK MyMsgProc (int nCode, WPARAM wParam, LPARAM lParam)

{

  // forward the other hook calls

  if ( nCode < 0 ) 

    return (CallNextHookEx(MyHook, nCode, wParam, lParam)); 

 

  LRESULT ret = CallNextHookEx(MyHook, nCode, wParam, lParam);

 

  // keep updating our cursor type

  SetCursor (hWaitCursor); 

 

  return (ret) ;

}


Comments

4 responses to “Setting the Wait Cursor type using ObjectARX and Win32”

  1. I don’t understand how the cursor looks; is it a Windows type cursor or a custom image?

  2. Is there a .net version of this?
    Cheers,
    Martin.

Leave a Reply to Alexander RivilisCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading