I'm trying to initialize a CListBox with a few strings in the
OnInitDialog function. This results in an Assert error everytime the
dialog is loaded.
The code that I'm using to populate the text box is as follows -
CString MenuOption;
MenuOption = "test";
m_MenuOptions.ResetContent();
m_MenuOptions.AddString(MenuOption);
I thought that the list box on the dialog was not getting initialized
for some reason and so decided to just see if it works once the dialog
is completely loaded. To try this out, I placed the AddString() code
in the event handler for a button on the dialog. This also gave me the
same assert error.
I've written the exact same code on Embedded Visual C++ for the pocket
PC and it worked like a charm. The related posts I've come accross
just recommend trying to place the AddString inthe OnInitDialog method
which I already am doing.
I'd really appreciate it if someone can point out what I'm messing up
here !
Thanks and Best Regards
Rohit.
2) What is the assertion that is failing?
--
Adam Clauss
cab...@tamu.edu
"_PacketStorm_" <r_...@indiatimes.com> wrote in message
news:236f5f64.03032...@posting.google.com...
The point where the assertion is failing is
void CListBox::DrawItem(LPDRAWITEMSTRUCT)
{ ASSERT(FALSE); }
<winctrl1.cpp>
Thanks in advance !!
Rohit.
"Adam Clauss" <cab...@tamu.edu> wrote in message news:<eup1b9a8...@TK2MSFTNGP11.phx.gbl>...
A thought: be sure you do the AddString's *after* you call the base-class's
OnInitDialog. Otherwise, the variable isn't attached to the window yet.
Jay
DrawItem is called if the list box "owner draw" style is turned on. You
probably don't want that style. Look for the owner draw checkbox in the
list box properties.
--
Scott McPhillips [VC++ MVP]