Add mouse event WM_RBUTTONDOWN on a button in Dialog based application.

I have my Dialog class here
class RS_232Conn : public CDialog
{
      DECLARE_DYNAMIC(RS_232Conn)
public:
      RS_232Conn(CWnd* pParent = NULL);   // standard constructor
      virtual ~RS_232Conn();
    // Insert into the applications .h header file

and I added a mouse message manager:
      afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
}
************************
Then in the .ccp application I have:
void RS_232Conn::OnRButtonDown(UINT nFlags, CPoint point)
{
      CPoint m_MousePoint;
      SetCapture();
      m_MousePoint =point;
      CDialog::OnRButtonDown(nFlags, point);
}  
*********
Now I can get the mouse right button event on my dialog box!
But how to get the mouse rightclick event on a BUTTON on the same Dialog box? Because it doesn't work on BUTTON !

if the IDC is like this?
      ON_BN_CLICKED(IDC_SYSTEMA, OnBnClickedSystema)

This is my question
Thanks for help
Marco53
marco53Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jaime OlivaresSoftware ArchitectCommented:
Insert a PreTranslateMessage event in your dialog object, then try to trap WM_RBUTTONDOWN message.
0
marco53Author Commented:
Can you explain with some code?
Where I have to insert this PreTranslateMessage function?
Thanks
Marco53
0
Jaime OlivaresSoftware ArchitectCommented:
Invoke the ClassWizard, pressing Ctrl-W, select your RS_232Conn object class, select the PreTranslateMessage event and create a function to handle it by pressing the AddFunction button.
Then go to edit the created function directly in you code.


BOOL RS_232Conn::PreTranslateMessage(MSG* pMsg)
{
    if (pMsg->message==WM_RBUTTONDOWN) {
         MessageBeep(MB_OK);   // test function
         // Pût your real action code here
    }
    return CDialog::PreTranslateMessage(pMsg);
}

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
marco53Author Commented:
Thanks a lot!
Marco53
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.