Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC - CListBox

Started by tordyvel Jan 23, 2005 at 2:38 PM 1 replies 600+ views
Original Post
tordyvel
tordyvel
Hi! I'm having big problems with CListBox. I'm making a mapeditor and I just made a dialog for it that has a List Box. But I can't add any items to the list box util i run doModal(). My ListBox control i called m_list and i've tried to add m_list.addString("test) everywhere but it doesn't show up when the dialogbox runs. I tried to add a "test" button to se if I could add a value when it runs, and that works perfectly. This is what i want to do: CTaglistDlg dlg; for(int i=0;i<10;i++) dlg.m_list.addString("testing"); dlg.DoModal(); but the list is empty when i run it. Thanks for your help!
T1mb0
T1mb0
In the moment you add the items, the box does not exist yet, and the addString-calls (translated into windows messages) will just be lost.

You should try to initialize the dialog in its WM_INITDIALOG message handler, as the controls will then be able to accept strings.
tordyvel
tordyvel
Thanks! It works great now! :D
I've been struggling with it for two hours. :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.