OnSetCursor and the keyboard
-
I am trying to have the cross cursor apear when you press down the control key. In the MSDN it says that message controls the mouse message number. When I run this code it does not recignise the key.
BOOL CClusterSimulationView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (message == MK_CONTROL) { hCursor = LoadCursor(NULL, IDC_CROSS); SetCursor(hCursor); } else { hCursor = LoadCursor(NULL, IDC_ARROW); SetCursor(hCursor); } return true; }
-
I am trying to have the cross cursor apear when you press down the control key. In the MSDN it says that message controls the mouse message number. When I run this code it does not recignise the key.
BOOL CClusterSimulationView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (message == MK_CONTROL) { hCursor = LoadCursor(NULL, IDC_CROSS); SetCursor(hCursor); } else { hCursor = LoadCursor(NULL, IDC_ARROW); SetCursor(hCursor); } return true; }
This works fine; [code] BOOL m_Cntrl = FALSE; BOOL CtestView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (m_Cntrl) { ::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS)); return true; } else { return CScrollView::OnSetCursor(pWnd, nHitTest, message); } } void CtestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { if(nChar == VK_CONTROL){ m_Cntrl = TRUE; } CScrollView::OnKeyDown(nChar, nRepCnt, nFlags); } void CtestView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { if(nChar == VK_CONTROL){ m_Cntrl = FALSE; } CScrollView::OnKeyUp(nChar, nRepCnt, nFlags); } [/code]