I have a problem using a combo box in a dialog. I am using masm32 and RadASM to create the dialog. I create a new project using the DialogApp template and draw a combo box onto the dialog. Then I add these lines to the .inc file:



.const
IDC_CBO1 equ 1001

.data?
cb_handle dd ?


And use this code to add four items to the dialog box:



mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem, hWin, IDC_CBO1
mov cb_handle, eax

jmp @123
item1 db "bytes",0
item2 db "kilobytes",0
item3 db "megabytes",0
item4 db "gigabytes",0
@123:

invoke SendMessage, cb_handle, CB_ADDSTRING, 0, ADDR item1
invoke SendMessage, cb_handle, CB_ADDSTRING, 0, ADDR item2
invoke SendMessage, cb_handle, CB_ADDSTRING, 0, ADDR item3
invoke SendMessage, cb_handle, CB_ADDSTRING, 0, ADDR item4


This works in that the items are all added correctly, the problem is the combobox will not drop down when you click it or on the down arrow. I know that the items are added correctly because if you use the mouse wheel or the arrow keys you can select one of the items but clicking on it doesn't do anything. What am I missing here?

Also I tried to use SendDlgItemMessage instead of SendMessage but this didn't add any items at all. Can someone give me an example using SendDlgItemMessage too?

Cheers :alright:
Posted on 2003-12-03 04:01:41 by DeX
DeX,

When you are in the RadASM's Dialog editor, make the dimensions of the ComboBox the size you would want when the ComboBox "Drops down". For instance, when a ComboBox is initially displayed on the screen the dimensions might be, 5 mm in height and 25 mm in width. When the ComboBox drops down, the dimensions might change to 25 mm in height and stay 25 mm in width. When you are creating the ComboBox, make the dimension 25 mm by 25 mm or any size you want.

HTH

farrier
Posted on 2003-12-03 04:33:48 by farrier
That worked thanks. Strange how when I saw an example of someone creating a combo box using the normal CreateWindowEx api instead of using a dialog that they set the height to 22 which is the normal height for a combo box. Why is it different when using a combo on a dialog box? Also does anyone know about the SendDlgItemMessage thing?

cheers
Posted on 2003-12-04 07:31:03 by DeX
In your case
invoke SendDlgItemMessage, hWin, IDC_CBO1, CB_ADDSTRING, 0, ADDR item1
should work as expected.
Posted on 2003-12-04 09:24:05 by Morris