-
CListBox
Hmmm.....
Something strange going on here.
I've created a ListBox in the resource editor in an existing CPropertyPage. When I use the Class Wizard to add a member variable, I add a CListBox control, called m_lbLog (standard creation flags). When I tried to add strings to the list box, I received an assert about it not being a valid m_hWnd. So, being the resourceful person I am, I called m_lbLog.Create() in OnInitDialog for the CpropertyPage and fill it with strings. The assert went away, but strings don't show up.
My question is twofold.
Should I have to call create if I create the CListBox from the Class Wizard?
And if so, what use are the flags in the Class Wizard when you place the control?
Thanks in advance.
-
Re: CListBox
You shouldn't have to create the control if you created it with the Class Wizard. Are you sure your adding the strings after the dialog has OnInit'ed? In the OnInitDialog function, make sure the added strings are after the parent call.
-
Re: CListBox
I've since gotten it working, without actually knowing what I've 'fixed'.
I deleted the CListBox and the item from the PropPage and added them again with the Class Wizard.
I was adding dummy strings just to test it OnInitDialog.
The code was as follows:
BOOL CPropPageLogging::OnInitDialog()
{
CPropertyPage::OnInitDialog();
RECT Rect = { /*Some values here.*/};
m_lbLog.Create( Flags, &Rect.... etc );
for( int i = 0; i < 200; i++ )
m_lbLog.AddString( -1, itoa( i, szBuf, 10 ) );
return( TRUE );
}
Preivously, without the explicit Create call, the code would Assert on "not a valid window handle" for the CListBox. After deleting and readding the ListBox control, everything was 'better'.
Makes you go hmmmm..... when things like this happen. I had tried 'rebuild all' prior to this just to clean out the build.
Thanks for the reply.
Mike