Link to home
Start Free TrialLog in
Avatar of Nevering
Nevering

asked on

Custom ComboBox in DialogBar

I've created a DialogBar that I would like to emulate the font drop-down list as in MS Word.  I have obtained a class from CodeGuru, named CustComboBox by Girish Bharadwaj.

I have subclassed the CDialogBar to CFontDlgBar, where I have added the member variables for the combo boxes, one of which is the CustComboBox.

The problem is that while the contructor for the CustComboBox is getting called correctly, nothing else is.  OnCreate is not getting called, and the overridden DrawItem, etc are not getting called.

Does anyone have any idea of what I'm doing wrong or missing, I'm lost.

thanks
Avatar of Recez
Recez

the combo box must be an owner-draw combo box
Avatar of Nevering

ASKER

It is owner drawn.. Set to Variable in rc, and Has Strings.


Hi!
Do you attach your MFC class to the windows control by SubclassDlgItem or DDX_Control?
Hm! A`m miss! You create DialogBar! its sligtly differ from creating Dialog. You must handle WM_INITIALUPDATE message in the your class and call here SubclassDlgItem method of the your ComboBox
WM_INITIALUPDATE doesn't seem to be available (in Wizard) in my DialogBar class.  I tried OnInitDialog, which was there, but that didn't work for DialgBar.  And it's the CustComboBox that I want to SubClassDlgItem on .. right ?  Then who handles the messages?  ... the DialogBar class ?

thanks
I think before you subclass dialog, the combbox in dialog
template have been created, so it couldn't receive
wm_create message again.
I think perhaps you try following code:
   CCombbox* pwnd = (CCombobox*)m_dialogbar.GetDlgItem(IDC_COMBOX1);
   pwnd->InsertString(...)
         
Hm, But WM_INITIALUPDATE is sended to the dialog by Frame!
to add handler to it just modify your MESSAGE MAP
for example:
//in the class declaration define handler of this message
{
///....
afx_msg LRESULT OnInitialUpdate(WPARAM, LPARAM );
///.....
}

// in the cpp file
BEGIN_MESSAGE_MAP(....)
// wizard generated entries
....
//
 ON_MESSAGE(WM_INITIALUPDATE , OnInitialUpdate)
END_MESSAGE_MAP();

// implementation
LRESULT CMyDialogBar::OnInitialUpdate(WPARAM, LPARAM)
{
if (!m_wndCombo.GetSafeHwnd())
   m_wndCombo.SubclassDlgItem(IDC_COMBO, this);
}
WM_INITIALUPDATE is undefined during compile ??
#include <afxpriv.h>
Migel, that seemed to have worked, please answer the question so that I can give you the points.

thanks
Nevering
ASKER CERTIFIED SOLUTION
Avatar of migel
migel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial