Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CListBox problems with AddString

160 views
Skip to first unread message

_PacketStorm_

unread,
Mar 23, 2003, 8:41:10 PM3/23/03
to
Hi..
I know this is something which has been discussed before in this grp
but I wasnt able to find any example which fits my situation.

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.

Adam Clauss

unread,
Mar 23, 2003, 9:45:09 PM3/23/03
to
1) Are you sure the variable is mapped correctly to the actual listbox.

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...

_PacketStorm_

unread,
Mar 24, 2003, 12:03:30 PM3/24/03
to
Hi,
Yup, I'm sure that the variable is mapped correctly - i've rechecked
that several times.

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>...

Jay Nabonne

unread,
Mar 24, 2003, 1:24:20 PM3/24/03
to

"_PacketStorm_" <r_...@indiatimes.com> wrote in message
news:236f5f64.03032...@posting.google.com...

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


Scott McPhillips

unread,
Mar 24, 2003, 8:59:39 PM3/24/03
to
_PacketStorm_ wrote:
>
> Hi,
> Yup, I'm sure that the variable is mapped correctly - i've rechecked
> that several times.
>
> The point where the assertion is failing is
>
> void CListBox::DrawItem(LPDRAWITEMSTRUCT)
> { ASSERT(FALSE); }
>
> <winctrl1.cpp>
>
> Thanks in advance !!
>
> Rohit.

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]

0 new messages