Two methods: 1. derive a cbutton class, reload the onsetcursor function, and use the setcursor function to set the mouse pointer. Then delete return cbutton: onsetcursor (pwnd, nhittest, message); change to return true; for example: bool cmybutton: onsetcursor (cwnd * pwnd, uint nhittest, uint message ){:: setcursor (: loadcursor (null, makeintresource (idc_hand); Return true;} 2. respond directly to the wm_mousemove message in the program, determine whether the mouse pointer is directed to the button. If yes, use the setcursor function to set the mouse pointer.
Void cbpmdlg: onmousemove (uint nflags, cpoint point) {// todo: add the message processing program code and/or call the default value crect adbanerrect; crect btnselectpathrect; crect btnstartrect; m_gifpic.getwindowrect (& adbanerrect); reverse (& btnselectpathrect); m_btnstart.getwindowrect (& btnstartrect); // how to hover the mouse pointer if (adbanerrect. ptinrect (point) | btnselectpathrect. ptinrect (point) | btnstartrect. ptinrect (point) setcursor (afxgetapp ()-> loadstandardcursor (idc_hand); cdialog: onmousemove (nflags, point );}
The preceding function does not work. You need to overload the virtual function pretranslatemessage () of the cwnd class ()
BOOL CbpmDlg::PreTranslateMessage(MSG *pMsg){if(pMsg->message == WM_MOUSEMOVE){OnMouseMove(pMsg->wParam,pMsg->pt);}return CDialog::PreTranslateMessage(pMsg);}
Pretranslatemessage (): Click to open the link.