Solved

Assigning a CLICK event to an CEdit box

Posted on 1997-08-21
4
366 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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