Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capturing clicks and double-clicks in Rich Edit controls

Posted on 1998-08-24
2
Medium Priority
?
267 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
[X]
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 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

704 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