Solved

How to get a Double Click Event for CEdit box?

Posted on 2002-07-26
2
698 Views
Last Modified: 2013-11-20
In Visual basic(VB) we have double click event for Text box (Edit box). But in Visual C++ MFC we don't have a double click event for edit box. All we have for this are SetFocus, KillFocus, Change etc. Is there any way we could get this double click event for Edit box like VB?
0
Comment
Question by:AniBala
2 Comments
 
LVL 8

Accepted Solution

by:
fl0yd earned 75 total points
ID: 7181207
It is inherited from the CWnd-parent. The function is called OnLButtonDblClick.
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 7183210
Hi,

Follow the steps to get the Double click event for the edit box.

1. Go to class wizard and add a new class say CTestEdit and derive it form CEdit class.

2. Using class wizard, go to member variables tab and add a member variable of type "control" and "CTestEdit" to the edit box id, say IDC_TEST_EDIT

3. As soon as u add a control type of CTestEdit, the classwizard will ask u to add the TestEdit.h to the zzzDlg.h file, where zzzDlg.h is ur dialog class header file on which u have placed the edit control.

4. Open the zzzDlg.h file and include "TestEdit.h" file to it.

5. Now go to class wizard and select the CTestEdit class. Then select WM_LBUTTONDBCLK message from "messages" list. Add the function to that message.

6. Now open the TestEdit.cpp file and u will find the OnLButtonDbClk(...) function. U add ur code here. say just AfxMessageBox("Edit double Clicked"); Now run and double click, u will see the message box pop up.

Now u can change the behaviour to whatever u want. This process is known as "Subclassing" and using this method u can subclass the controls and get the behaviour of ur desire.

Try it out.
VinExpert
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

825 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