Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OnSetCursor and the keyboard

OnSetCursor and the keyboard

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JadziaMD
    wrote on last edited by
    #1

    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; }

    B 1 Reply Last reply
    0
    • J JadziaMD

      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; }

      B Offline
      B Offline
      Burz
      wrote on last edited by
      #2

      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]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups