dcoggin1
asked on
Unable to load cursor in MFC CView class
I am trying to change the cursor when panning. I have created member variables for the cursors:
HCURSOR m_hArrowCursor;
HCURSOR m_hPanCursor;
I initialize the variables in PreCreateWindow:
m_hArrowCursor = AfxGetApp()->LoadCursor(ID C_ARROW);
m_hPanCursor = AfxGetApp()->LoadCursor(ID C_SIZEALL) ;
When I need to change the cursor I set a bit in a unsigned int variable m_iCursorState
I have overridden the OnSetCursor function:
BOOL CMyView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if (m_iCursorState & PAN_CURSOR)
{
::SetCursor(m_hPanCursor);
return true;
}
else if (m_iCursorState & ARROW_CURSOR)
{
::SetCursor(m_hArrowCursor );
return true;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
The code compiles fine but I get no cursor when the mouse is in the client area. If I check the value of the cursor handle variables, they are all zeros. Is there something special required to get access to the standard cursors?
Thanks for your help,
David
HCURSOR m_hArrowCursor;
HCURSOR m_hPanCursor;
I initialize the variables in PreCreateWindow:
m_hArrowCursor = AfxGetApp()->LoadCursor(ID
m_hPanCursor = AfxGetApp()->LoadCursor(ID
When I need to change the cursor I set a bit in a unsigned int variable m_iCursorState
I have overridden the OnSetCursor function:
BOOL CMyView::OnSetCursor(CWnd*
{
if (m_iCursorState & PAN_CURSOR)
{
::SetCursor(m_hPanCursor);
return true;
}
else if (m_iCursorState & ARROW_CURSOR)
{
::SetCursor(m_hArrowCursor
return true;
}
return CView::OnSetCursor(pWnd, nHitTest, message);
}
The code compiles fine but I get no cursor when the mouse is in the client area. If I check the value of the cursor handle variables, they are all zeros. Is there something special required to get access to the standard cursors?
Thanks for your help,
David
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER