VC changes the mouse pointer to a button into a hand shape

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.