Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Dimitar Lazarov
|
Sep 14, 2006 - 10:54 AM
|
Hi, I try to create readonly combobox. How I can do it easy with CExtComboBox?
Thanks Dimitar
|
|
Technical Support
|
Sep 14, 2006 - 12:20 PM
|
You can do this by overriding the CExtComboBoxBase::OnSubclassInnerEdit() : void CYourComboBox::OnSubclassInnerEdit()
{
CExtComboBox::OnSubclassInnerEdit();
if( m_wndInnerEditHook.GetSafeHwnd() != NULL )
m_wndInnerEditHook.SetReadOnly();
}
|
|
Dimitar Lazarov
|
Sep 15, 2006 - 3:14 AM
|
First thanks for quick replay :-). This works when the combo style is CBS_DROPDOWN (not CBS_DROPDOWNLIST) and combo is enabled. The style is not a problem - I can change it at run time, but what can I do when the combo is disabled? I want users to be able to copy the text from disabled combobox.
Thanks Dimitar
|
|
Technical Support
|
Sep 15, 2006 - 11:10 AM
|
When the combo box gets a WM_ENABLE message, check the bEnable flag and call EnableWindow and SetReadOnly for the edit box. BEGIN_MESSAGE_MAP(CYourComboBox, CExtComboBox)
...
ON_WM_ENABLE()
...
END_MESSAGE_MAP()
void CYourComboBox::OnEnable( BOOL bEnable )
{
CExtComboBox::OnEnable( bEnable );
if( m_wndInnerEditHook.GetSafeHwnd() == NULL )
{
m_wndInnerEditHook.EnableWindow( TRUE );
m_wndInnerEditHook.SetReadOnly( !bEnable );
}
}
|
|
Dimitar Lazarov
|
Sep 18, 2006 - 5:55 AM
|
Thanks again but this sample is not working! The combo and the m_wndInnerEditHook edit control are still disabled (may be because m_wndInnerEditHook is a child window of the combo and we cannot enable child window while the parent is disabled). Any other ideas?
Thanks Dimitar
|
|
Technical Support
|
Sep 19, 2006 - 10:38 AM
|
We are sorry but this is impossible. You cannot work with the window whose parent window is disabled. The combo box should be enabled.
|
|