CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    mouse over a pushbutton

    I can use the CPoint object for knowing position in a dialog box. How can I tell if my mouse is positioned over a pushbutton. This would be similar to a tooltip however, I don't want to tell the user what the pushbutton does. I want to do something else if they are over the pushbutton. This will be done in OnMouseMove()


  2. #2
    Join Date
    May 1999
    Posts
    31

    Re: mouse over a pushbutton

    Hi,

    You could do something like this:

    CRect rectButton;
    POINT ptCursorPos;

    GetDlgItem(IDC_YOURBUTTON)->GetWindowRect(rectButton);
    GetCursorPos(&ptCursorPos);

    if (rectButton.PtInRect(ptCursorPos))
    {
    // Do Something
    }

    Daniel.


  3. #3
    Join Date
    Apr 1999
    Posts
    383

    Re: mouse over a pushbutton

    Do the check from within the MouseMove handler (which passes you the current mouse position), by getting the window rect of the button as Daniel suggests.

    Dave


  4. #4
    Join Date
    May 1999
    Posts
    78

    Re: mouse over a pushbutton

    i m sure i downloaded some project from CODEGURU a week ago that was doing what you wanted...serach i the articles published and there is a downloadable one that does what you want..........


  5. #5
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: mouse over a pushbutton

    Subclass the pushbuttons and in its OnMouseMove go and do your stuff.....

    Sally


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured