Solved

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

Posted on 2004-11-01
530 Views
Last Modified: 2008-03-03
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
0
Question by:marco53
    4 Comments
     
    LVL 55

    Expert Comment

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

    Author Comment

    by:marco53
    Can you explain with some code?
    Where I have to insert this PreTranslateMessage function?
    Thanks
    Marco53
    0
     
    LVL 55

    Accepted Solution

    by:
    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
     

    Author Comment

    by:marco53
    Thanks a lot!
    Marco53
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    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…
    This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…
    Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now