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. How to change mouse cursor when move mouse pass the button?

How to change mouse cursor when move mouse pass the button?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 3 Posters 18 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button? This is my easy win32 code, please edit or modify this code below. Thank you. #include "afxwin.h" #define IDC_BUTTON1 100 class CApp:public CWinApp{ public: virtual BOOL InitInstance(); }; CApp app; class CWin:public CFrameWnd{ CButton *button; public: CWin(); ~CWin(); }; BOOL CApp::InitInstance(){ m_pMainWnd=new CWin(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; }; CWin::CWin(){ Create(NULL,"Hello", WS_OVERLAPPEDWINDOW,CRect(0,0,200,200)); button=new CButton(); button->Create("OK", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(50,50,100,100),this,IDC_BUTTON1); } CWin::~CWin(){ delete button; }

    J G 2 Replies Last reply
    0
    • L Lost User

      How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button? This is my easy win32 code, please edit or modify this code below. Thank you. #include "afxwin.h" #define IDC_BUTTON1 100 class CApp:public CWinApp{ public: virtual BOOL InitInstance(); }; CApp app; class CWin:public CFrameWnd{ CButton *button; public: CWin(); ~CWin(); }; BOOL CApp::InitInstance(){ m_pMainWnd=new CWin(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; }; CWin::CWin(){ Create(NULL,"Hello", WS_OVERLAPPEDWINDOW,CRect(0,0,200,200)); button=new CButton(); button->Create("OK", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(50,50,100,100),this,IDC_BUTTON1); } CWin::~CWin(){ delete button; }

      J Offline
      J Offline
      Jeremy Davis
      wrote on last edited by
      #2

      Don't quote me on this BUT I think you could try setting the cursor using SetCursor in OnSetCursor - WM_SETCURSOR.

      1 Reply Last reply
      0
      • L Lost User

        How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button? This is my easy win32 code, please edit or modify this code below. Thank you. #include "afxwin.h" #define IDC_BUTTON1 100 class CApp:public CWinApp{ public: virtual BOOL InitInstance(); }; CApp app; class CWin:public CFrameWnd{ CButton *button; public: CWin(); ~CWin(); }; BOOL CApp::InitInstance(){ m_pMainWnd=new CWin(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; }; CWin::CWin(){ Create(NULL,"Hello", WS_OVERLAPPEDWINDOW,CRect(0,0,200,200)); button=new CButton(); button->Create("OK", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(50,50,100,100),this,IDC_BUTTON1); } CWin::~CWin(){ delete button; }

        G Offline
        G Offline
        Gary Menzel
        wrote on last edited by
        #3

        There are two possible ways of implementing this (that I know of). Both of them include trapping either one or both of the MOUSEMOVE or SETCURSOR messages. You can either trap them at level of the main FrameWnd or in the Button (I would personally prefer to subclass the Button and trap it in there so I could reuse that new button in other parts of my code). In the case of trapping it in the FrameWnd (probably trapping MOUSEMOVE after you know the cursor is in the FrameWnd - using SETCURSOR to set some flag) you then need to work out if the mouse is over the button to change to the IBEAM cursor - as well as not over the button to change it back!!). There are probably other pitfalls to worry about that my simple explanation doesn't cover but they would be the two basic approaches to consider. Regards, Gary Menzel ================== The original message was: How to change mouse cursor to "IDC_IBEAM" when move mouse pass the button?

        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