Solved

Assigning a CLICK event to an CEdit box

Posted on 1997-08-21
4
370 Views
Last Modified: 2013-11-20
I have a VC++ 4.x app that has several edit boxes created with the dialog editor in VC (standard CEdit box). How can I assign a CLICK event to these? CLICK is not a standard stock event, and I cannot seem to add a custom event. Example code would be great. Thanks.

Michael A Knight
0
Comment
Question by:maknight
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1304529
If you want to know when an edit control is clicked on, you can derive a class from CEdit and catch the WM_LBUTTONDOWN message. This message is sent when the user clicks on the edit control.
0
 

Author Comment

by:maknight
ID: 1304530
I have tried this, but if I use ClassWizard to add a Member Variable for the CEdit control of category Control and type KECEditCtrl (the CEdit-derived class), everywhere I click in the dialog (it is a Dialog-based app) runs the ON_WM_LBUTTONDN code in the derived class. This puzzles the heck outta me.
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1304531
This is very puzzling. The only way that could happen is your derived class is the one stealing all of the mouse messages. Make sure there's no reference to CEdit anywhere in your dialog class. Check to make sure no one is explicitly calling your OnLButtonDown function.

0
 

Author Comment

by:maknight
ID: 1304532
I found the culprits. A) Remove the default call from the end of the OnLButtonDn function, B) SetFocus to the edit control. Somehow in the derivation, the system loses light of the fact that it should set focus on the click also. Thanks. I have another related question I just posted if you wanna take a shot at it...

MAK
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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