Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2004-11-01
Medium Priority
Last Modified: 2008-03-03
I have my Dialog class here
class RS_232Conn : public CDialog
      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;
      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
Question by:marco53
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12473165
Insert a PreTranslateMessage event in your dialog object, then try to trap WM_RBUTTONDOWN message.

Author Comment

ID: 12479368
Can you explain with some code?
Where I have to insert this PreTranslateMessage function?
LVL 55

Accepted Solution

Jaime Olivares earned 2000 total points
ID: 12487392
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);


Author Comment

ID: 12489294
Thanks a lot!

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question