Subclassing Controls 
Author Message
 Subclassing Controls

Hi Gang,
Simple question.... (I Hope)..

I want to take a Cedit control and subclass it.

Then, I'd like to take two different controls and place them on my dialog
box.

What I'm trapping for is the OnChar command.  I'm looking for a function
key, when hit, to process some value lookup, etc.

What I can't figure out is how I know what control I'm sitting on.

Let's apply this to a database, I'll use the F4 key to do lookups into the
database.  Thing is, I need to know what field I am sitting on to go do my
lookups in.

Question is, how do I know which one I am on?

Thanks,
Nick

env: W2K/sp1, VC6/sp5



Sat, 18 Oct 2003 11:30:39 GMT  
 Subclassing Controls

Quote:

> Hi Gang,
> Simple question.... (I Hope)..

> I want to take a Cedit control and subclass it.

> Then, I'd like to take two different controls and place them on my dialog
> box.

> What I'm trapping for is the OnChar command.  I'm looking for a function
> key, when hit, to process some value lookup, etc.

> What I can't figure out is how I know what control I'm sitting on.

> Let's apply this to a database, I'll use the F4 key to do lookups into the
> database.  Thing is, I need to know what field I am sitting on to go do my
> lookups in.

> Question is, how do I know which one I am on?

> Thanks,
> Nick

> env: W2K/sp1, VC6/sp5

If called from a CEdit-derived class GetDlgCtrlID returns the edit
control's ID.

--
Scott McPhillips [VC++ MVP]



Sat, 18 Oct 2003 11:48:51 GMT  
 Subclassing Controls
Are you familiar with subclassing controls using the techniques described in
the following:

http://www.cpp.atfreeweb.com/SubclassingControls.html
http://www.cpp.atfreeweb.com/DerivedControls.html

If not then familiarizing yourself with those techniques will help
immensely. The default processing of keyboard messages such as WM_CHAR is
for them to never be sent to a dialog unless the dialog is totally empty of
anything else for them to go to. That is the way you want things to work
because then the control receinving the message knows who got the key; the
control that gets the message got the key. However, in the case of many
non-ASCII keys such as function keys, the WM_CHAR message is not sent; you
will need to process a WM_KEYDOWN (or WM_KEYUP) message.

For an application such as this, a SDI application using CFormView would
probably be easier over-all because some of the things you want to do and
will want to do will actually be easier than in a dialog-based application.


Quote:
> Hi Gang,
> Simple question.... (I Hope)..

> I want to take a Cedit control and subclass it.

> Then, I'd like to take two different controls and place them on my dialog
> box.

> What I'm trapping for is the OnChar command.  I'm looking for a function
> key, when hit, to process some value lookup, etc.

> What I can't figure out is how I know what control I'm sitting on.

> Let's apply this to a database, I'll use the F4 key to do lookups into the
> database.  Thing is, I need to know what field I am sitting on to go do my
> lookups in.

> Question is, how do I know which one I am on?

> Thanks,
> Nick

> env: W2K/sp1, VC6/sp5



Sat, 18 Oct 2003 13:33:41 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Subclassing controls

2. Subclassing controls

3. subclassing controls in dynamically biult dialog box

4. subclassing controls in CFormView

5. subclassing controls w/ ActiveX

6. Subclassing Control (pref. RichEdit)

7. Subclassing controls

8. Subclassing controls

9. Subclassing controls in a composite control within the container class.

10. Subclassing the header control inside list control

11. Help:ACIVEX controls- subclassing Windows Control

12. Subclassing an ActiveX control

 

 
Powered by phpBB® Forum Software