Solved

How to get a Double Click Event for CEdit box?

Posted on 2002-07-26
2
686 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now