[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

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
0
marco53
Asked:
marco53
  • 2
  • 2
1 Solution
 
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
 
marco53Author Commented:
Thanks a lot!
Marco53
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now