Subclassing controls 
Author Message
 Subclassing controls

I have read some solutions that said you should subclass a control in order
to do certain things such as intercept messages. What I was wondering was
how to you do this.
For example I was told in order to stop a text box from highlighting the
text when it receives focus I should subclass it and intercept the
selection message. What is the syntax to subclass this text box, and how do
I intercept the messages sent to it?
  Please be detailed and technical with the answer, I'm up to it.
  Thank you very much,



Sat, 16 Oct 1999 03:00:00 GMT  
 Subclassing controls

: I have read some solutions that said you should subclass a control in order
: to do certain things such as intercept messages. What I was wondering was
: how to you do this.
: For example I was told in order to stop a text box from highlighting the
: text when it receives focus I should subclass it and intercept the
: selection message. What is the syntax to subclass this text box, and how do
: I intercept the messages sent to it?
:   Please be detailed and technical with the answer, I'm up to it.

It's quite simple.  If you have a control, i.e. an edit control,
then create a class derived from a CEdit (if using MFC).  Then map
a handler for the message you want to intercept.

Now, here is how you subclass the control.  Let's say you have a
control with id IDC_EDIT1. Then do this:

        CMyEditClass m_edit1; // declared somewhere.

        m_edit1.SubclassDlgItem(IDC_EDIT1, this);  // this = parent window.

I told you it was trivial :).

:   Thank you very much,

Good luck,
--
Donald
**************************************************************
* I got a Mantis in my Pantis.                               *
* Professor, pathology is limited, it's pathetic!            *
* -- Mystery Science Theater 3000                            *
**************************************************************

*Samples:ftp://ftp.hpc.uh.edu/pub/donald                     *
**************************************************************



Sat, 16 Oct 1999 03:00:00 GMT  
 Subclassing controls


Quote:

>: I have read some solutions that said you should subclass a control in order
>: to do certain things such as intercept messages. What I was wondering was
>: how to you do this.
>: For example I was told in order to stop a text box from highlighting the
>: text when it receives focus I should subclass it and intercept the
>: selection message. What is the syntax to subclass this text box, and how do
>: I intercept the messages sent to it?
>:   Please be detailed and technical with the answer, I'm up to it.

>It's quite simple.  If you have a control, i.e. an edit control,
>then create a class derived from a CEdit (if using MFC).  Then map
>a handler for the message you want to intercept.

>Now, here is how you subclass the control.  Let's say you have a
>control with id IDC_EDIT1. Then do this:

>        CMyEditClass m_edit1; // declared somewhere.

>        m_edit1.SubclassDlgItem(IDC_EDIT1, this);  // this = parent window.

>I told you it was trivial :).

Another way to do this is to use DDX_Control() in DoDataExchange().  This also
subclasses the control.

--------------------------------------------------------------------------------


XIOtech Corporation               Personal Home Page:   http://www.visi.com/~nde
Eden Prairie, MN

"Question authority...and the authorities will end up questioning YOU!"
--------------------------------------------------------------------------------



Sat, 16 Oct 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Subclassing controls

2. subclassing controls in dynamically biult dialog box

3. subclassing controls in CFormView

4. Subclassing Controls

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