Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Capturing clicks and double-clicks in Rich Edit controls

Posted on 1998-08-24
2
Medium Priority
?
268 Views
Last Modified: 2013-11-20
Environment: VC++ 5.0, Win NT 4.0

I am writing an application using Rich Edit controls in a modal dialog box.  I want to capture when the user clicks or doubleclicks on the Rich Edit control, but have so far been unable to do this.  When I do this with CEdit's, it works right away, so I must have to do something more than simply adding the function OnClickRichEdit through the dialog editor.  What can I do?

/Claus
0
Comment
Question by:Claus
2 Comments
 
LVL 1

Accepted Solution

by:
amby earned 50 total points
ID: 1321213
A solution is to define a new window proc for your control in your application...

example:
--------

long OldWndProc;

CMyDialog::InitDialog(...)
{
  //... Code Before

  OldWndProc=SetWindowLong(m_MyRichEdit.m_hWnd, GWL_WNDPROC, (long) NewWndProc);

  //... Code After
}

LRESULT CALLBACK NewWndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
  // this is the new wnd proc
  switch (uMsg) {

  case WM_LBUTTONDOWN:
    //... code
    break;

  case WM_LBUTTONUP:
    //... code
    break;
  }

  return CallWindowProc((WNDPROC)OldWndProc, hwnd, uMsg, wParam, lParam);
}

another solution is to make a class derived from CRichEditControl but someone here has already done this and it is really lot of work

in this second case, you declare

class CMyRichEditControl : public CRichEditControl
{
  ...

  // Generated message map functions
  //{{AFX_MSG(CMyRichEditControl)
    afx_msg MYRETVAL OnlButtonDown(WPARAM, LPARAM ); // added manually
    ...
  //}}AFX_MSG
  DECLARE_MESSAGE_MAP()
};

in the definition file:
-----------------------

BEGIN_MESSAGE_MAP(CMyRichEditControl, CRichEditControl)
  //{{AFX_MSG_MAP(CMixerMainDlg)
  ON_MESSAGE(WM_LBUTTONDOWN, OnlButtonDown)
END_MESSAGE_MAP()

MYRETVAL CMyRichEditControl::OnlButtonDown(WPARAM wParam, LPARAM lParam)
{
  //... blah blah
}


I prefer first solution...
0
 

Author Comment

by:Claus
ID: 1321214
I found a better solution myself in the meantime.  I can catch the messages in the PreTranslateMessage of the main dialog box.  The code looks somewhat like this:

BOOL CTbuilderDlg::PreTranslateMessage(MSG* pMsg)
{
      CRichEditCtrl *sub;

      sub = (CRichEditCtrl *)GetDlgItem(IDC_SUB2);

      switch ( pMsg->message)
      {
            case WM_LBUTTONDBLCLK:
                  if (pMsg->hwnd == sub->m_hWnd)
                        MessageBox("", "", MB_OK);
                  break;
      }

      return CDialog::PreTranslateMessage(pMsg);
}

/Claus

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

773 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