Changing cursor

Hi,
I am interested in changing the cursor from the standard arrow pointer to something else (like the rotation symbol used in word). Any ideas on how to do this would be appreciated.
P.S. I tried LoadCursor(...) but can not get it to change for some reason.
Thanks
[294 byte] By [stuckhere80] at [2007-11-18 22:15:34]
# 1 Re: Changing cursor
This is from Jeff Prosise "Programming Windows with MFC".

In one of his sample codes, he loads a cross-hair cursor using the following code:

CSketchView::CSketchView()
{
m_hCursor = AfxGetApp ()->LoadStandardCursor (IDC_CROSS);
}
where m_hCursor is a member of CSketchView of type HCURSOR. CSketchView is the view object. Hope this helps.
kodeguruguy at 2007-11-11 1:04:28 >
# 2 Re: Changing cursor
Originally Quoted by StuckHere80
I am interested in changing the cursor from the standard arrow pointer to something else (like the rotation symbol used in word). Any ideas on how to do this would be appreciated.

One method might be to process the WM_SETCURSOR message (OnSetCursor (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.onsetcursor.asp) )if you want to change the cursor according to events in the program:

BOOL CGraphWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
//When the context menu is called keep the arrow cursor on the context menu.
if(message !=0)
{
if(m_CursorOn)
{
SetCursor(AfxGetApp()->LoadCursor(CUR_CURSOR));
return TRUE;
}
}
return CWnd::OnSetCursor(pWnd, nHitTest, message);
}

Or, an additional method would be to Override the PreCreateWindow (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CWnd.3a3a.PreCreateWindow.asp) function if you want the cursor to always have the same cursor for the window(or View)(except when it is changed by OnSetCursor) :

BOOL CGraphWnd::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CWnd::PreCreateWindow(cs))
return FALSE;

cs.dwExStyle |=WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
AfxGetApp()->LoadCursor(CUR_CURSOR), HBRUSH(COLOR_WINDOW+1), NULL);
return TRUE;
}

The LoadCursor (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwinapp.3a3a.loadcursor.asp) function is for cursors from the resource file. To load a standard system cursor use LoadStandardCursor (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwinapp.3a3a.loadstandardcursor.asp) instead.
TDM at 2007-11-11 1:05:30 >