Subclassing edit-control of CComboBox 
Author Message
 Subclassing edit-control of CComboBox

I have a class MyEdit which is derived from CEdit.
By subclassing (and some additional initializing) I can transform an
edit-control in a dialogtemplate to a MyEdit-control.
Now I want to do a similar thing to the edit-control-part of CComboBox. Is
this possible? (is the edit-control-part of a CComboBox a CEdit-instance
that I can subclass?).

Thanks for your help!!!



Mon, 01 Dec 2003 21:14:55 GMT  
 Subclassing edit-control of CComboBox
Search for

        "HOWTO: Subclass CListBox and CEdit Inside of CComboBox"

    in your vc++ help.

Cheers
Check Abdoul
------------------


Quote:
> I have a class MyEdit which is derived from CEdit.
> By subclassing (and some additional initializing) I can transform an
> edit-control in a dialogtemplate to a MyEdit-control.
> Now I want to do a similar thing to the edit-control-part of CComboBox. Is
> this possible? (is the edit-control-part of a CComboBox a CEdit-instance
> that I can subclass?).

> Thanks for your help!!!




Mon, 01 Dec 2003 21:51:43 GMT  
 Subclassing edit-control of CComboBox
Hi Abdoul,

I can't find it. Can you tell me the name of the section/book/article in
InfoView?

Thanks,
Jos Landsheer


Quote:
>Search for

>        "HOWTO: Subclass CListBox and CEdit Inside of CComboBox"

>    in your vc++ help.

>Cheers
>Check Abdoul
>------------------



Tue, 02 Dec 2003 17:45:01 GMT  
 Subclassing edit-control of CComboBox
Found it! (it was in the Knowledge Base; not in the help).

Jos Landsheer



Tue, 02 Dec 2003 18:50:33 GMT  
 Subclassing edit-control of CComboBox
Sometimes our answers are not as clear as they can be, but anytime you see a
title prefixed with "HOWTO:" you can assume it is a KB article. Check Abdoul
assumed that it would be obvious but it is not so obvious to those that have
not seen numerous KB articles. I sometimes make invalid assumptions such as
that too.


Quote:
> Found it! (it was in the Knowledge Base; not in the help).

> Jos Landsheer



Tue, 02 Dec 2003 21:01:29 GMT  
 Subclassing edit-control of CComboBox


Wed, 18 Jun 1902 08:00:00 GMT  
 Subclassing edit-control of CComboBox
I subclassed the edit-box-part of a combo box, using the method described in
the 'HOWTO: Subclass CListBox and CEdit Inside of CComboBox'-article in the
Knowledge Base (by doing the subclassing during the processing of OnCtlColor
of the combobox).
It works, but it doesn't work fine. The problem is that I want to initialize
the edit-box-part with text in the OnInitDialog-function of the dialog of
which it is part. At that moment the control is not visible, so the combobox
OnCtlColor-function is not yet processed, so the edit-box-part is not
subclassed.

Example:

BOOL Test::OnInitDialog()
{
    m_mycombo.SubclassDlgItem(IDC_COMBO,this);
                    /*m_mycombo is of class MyCombo, which is derived of
CComboBox*/
    CDialog::OnInitDialog();
    m_mycombo.init("Hello world"); /*alas: this before MyCombo::OnCtlColor*/
    return TRUE;

Quote:
}

HBRUSH MyCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    if (nCtlColor == CTLCOLOR_EDIT) {
          if (m_myedit.GetSafeHwnd() == NULL) {  /*m_myedit is of class
MyEdit, which is derived of CEdit*/
               m_myedit.SubclassWindow(pWnd->GetSafeHwnd());
        }
    }
    return CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);

Quote:
}

My question:
Is there an earlier moment to do the
'm_myedit.SubclassWindow(pWnd->GetSafeHwnd());'-call?

Thanks,

Jos Landsheer



Mon, 08 Dec 2003 21:46:48 GMT  
 Subclassing edit-control of CComboBox
Have you tried calling SetWindowText on the combobox directly?

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> I subclassed the edit-box-part of a combo box, using the method described
in
> the 'HOWTO: Subclass CListBox and CEdit Inside of CComboBox'-article in
the
> Knowledge Base (by doing the subclassing during the processing of
OnCtlColor
> of the combobox).
> It works, but it doesn't work fine. The problem is that I want to
initialize
> the edit-box-part with text in the OnInitDialog-function of the dialog of
> which it is part. At that moment the control is not visible, so the
combobox
> OnCtlColor-function is not yet processed, so the edit-box-part is not
> subclassed.

> Example:

> BOOL Test::OnInitDialog()
> {
>     m_mycombo.SubclassDlgItem(IDC_COMBO,this);
>                     /*m_mycombo is of class MyCombo, which is derived of
> CComboBox*/
>     CDialog::OnInitDialog();
>     m_mycombo.init("Hello world"); /*alas: this before

MyCombo::OnCtlColor*/

- Show quoted text -

Quote:
>     return TRUE;
> }

> HBRUSH MyCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
> {
>     if (nCtlColor == CTLCOLOR_EDIT) {
>           if (m_myedit.GetSafeHwnd() == NULL) {  /*m_myedit is of class
> MyEdit, which is derived of CEdit*/
>                m_myedit.SubclassWindow(pWnd->GetSafeHwnd());
>         }
>     }
>     return CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
> }

> My question:
> Is there an earlier moment to do the
> 'm_myedit.SubclassWindow(pWnd->GetSafeHwnd());'-call?

> Thanks,

> Jos Landsheer




Mon, 08 Dec 2003 23:18:30 GMT  
 Subclassing edit-control of CComboBox
In principle you should be able to simply SetWindowText on the combo
box. If your subclassing has to be done first, then use PostMessage to
post a user-defined message to the dialog during OnInitDialog; by the
time it is processed, the control is already visible.
                        joe



Quote:
>I subclassed the edit-box-part of a combo box, using the method described in
>the 'HOWTO: Subclass CListBox and CEdit Inside of CComboBox'-article in the
>Knowledge Base (by doing the subclassing during the processing of OnCtlColor
>of the combobox).
>It works, but it doesn't work fine. The problem is that I want to initialize
>the edit-box-part with text in the OnInitDialog-function of the dialog of
>which it is part. At that moment the control is not visible, so the combobox
>OnCtlColor-function is not yet processed, so the edit-box-part is not
>subclassed.

>Example:

>BOOL Test::OnInitDialog()
>{
>    m_mycombo.SubclassDlgItem(IDC_COMBO,this);
>                    /*m_mycombo is of class MyCombo, which is derived of
>CComboBox*/
>    CDialog::OnInitDialog();
>    m_mycombo.init("Hello world"); /*alas: this before MyCombo::OnCtlColor*/
>    return TRUE;
>}

>HBRUSH MyCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
>{
>    if (nCtlColor == CTLCOLOR_EDIT) {
>          if (m_myedit.GetSafeHwnd() == NULL) {  /*m_myedit is of class
>MyEdit, which is derived of CEdit*/
>               m_myedit.SubclassWindow(pWnd->GetSafeHwnd());
>        }
>    }
>    return CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
>}

>My question:
>Is there an earlier moment to do the
>'m_myedit.SubclassWindow(pWnd->GetSafeHwnd());'-call?

>Thanks,

>Jos Landsheer


Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Tue, 09 Dec 2003 12:35:21 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Trouble subclassing the edit control of a CComboBox

2. (Q) Subclassing CComboBox edit control

3. Selchange after subclassing List- and edit part ofderived CComboBox

4. Subclassing an edit control to do custom word wrapping

5. Subclassing the edit control in CEditView

6. Subclassing Edit control

7. SubClassing Edit Control in CEditView

8. SubClassing a CEdit Control for Masked Edit.

9. Help ! Subclassing edit control

10. Help ! Subclassing edit control

11. Edit Control...Edit Control...Edit Control...Edit Control...Edit Control...

12. CComboBox: Getting Text from the Edit Control

 

 
Powered by phpBB® Forum Software