Solved

Detect Rt Mouse in Dialog

Posted on 1997-03-21
1
306 Views
Last Modified: 2011-09-20
I am trying to detect a right mouse button cllick in an edit control within a dialog.
I have coded :
BEGIN_MESSAGE_MAP
   On_WM_RBUTTONDOWN()
  ...
END_MESSAGE_MAP

-- in dialog class definition --
Protected:
  afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  ...

-- in dialog class coding --
void CSect2::OnRButtonDown(UINT nFlags, CPoint point)
{
    CWnd*  pCurWnd;

   pCurWnd = WindowFromPoint(point);
   if (pCurWnd == GetDlgItem(IDC_ITEM))
   {
       ......
   }

In debug mode, I get a break if mouse cllick is in dialog window outside of the edit control, but no break if mouse click is in edit control.
How do I detect a right mouse click in the edit control ?
Any help is appreciated.  Thanks.
0
Comment
Question by:PLRoss
[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
1 Comment
 

Accepted Solution

by:
joesynaptics earned 100 total points
ID: 1162321

One way you can deal with this is to subcalss the MFC Edit
control.

A reference for this process is "Inside Visual C++", page
346 ff.

Assume you have a edit field IDC_EDIT1.

Construct a new class CMyEdit which derives from CEdit.

In that class, map the WM_RBUTTON_DOWN message as you
did in the example above.

Write a handler for CMyEdit::OnRButtonDown.

Declare a CMyEdit in your dialog class definition.
Lets say that you call it m_foo.

In your OnInitDialog function for your dialog class:

m_foo.SubclassDlgItem(IDC_EDIT1, this);


Disclosure:
My answer is adapted from  "Indisde Visual C++" by
David J. Kruglinski, Microsoft Press, used without
permission.  Any errors are my responsibility, not
his, of course.

--Joe Decker




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.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

717 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