Hi all,

Is this the correct way to populate a list box, as it doesn't seem to be working for me?

1002 (IDC_LST1) is the number of the list box. Classname is just a db with some text in it.  Unfortunately it does not make an appearace in the list box. hWin is the dialogue box in which the list box resides.

WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
push hWin
pop hWnd
invoke LoadIcon,hInstance,500
mov hIcon,eax
invoke SendMessage,hWin,WM_SETICON,NULL,hIcon
invoke SendDlgItemMessage,hWin,1002,ClassName,NULL,NULL
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh

Posted on 2006-01-02 07:31:59 by WongDai
Hello WongDai,

To populate listbox use: 
invoke SendMessage,hListBox,LB_ADDSTRING,0,ADDR ClassName

handle must be handle to listbox not to dialog box.

best regards,

Posted on 2006-01-02 08:38:48 by czDrillard
Thankyou czDrillard

I am using RadASM, and as such the listbox is created in the dialogue editor.  I can see in the code where the actual dialogue box is created and thus know its handle is in hWin. 

How can I determine the handle of the listbox as it is created in the resource file?

Sorry for my noobness.

Posted on 2006-01-02 18:05:05 by WongDai
Hello WongDai,

Not necessary to apologize  :lol:

invoke GetDlgItem,hWin,1002

Listbox handle is returned in eax

best regards,

Posted on 2006-01-02 20:50:22 by czDrillard
Aha!  It works!

Thanks mate - well done.

Two wins in the first week of 2006.  W00t.

Posted on 2006-01-03 03:20:36 by WongDai

You can also just skip a step and use SendDlgItemMessage, it will take the handle of the dialog and the ID of the listbox. Generally that's what I tend to use unless I need to use it outside the message loop.
Posted on 2006-01-09 12:49:44 by donkey
Good one!

Thanks for the tip Donkey.

Posted on 2006-01-09 23:06:27 by WongDai