How do I use the ComboBox control ? I created it with a resource editor and I tried adding text to it but it didn't do it and nothing gets displayed. Any help is appreciated. Thanks Goatass
Try clicking on the combo box which you've added strings to, and pressing the up/down keys. Does it scroll through them? It took me about 4 emails with Iczelion to figure it out too. The problem lies in the creation of the combo box, what you need to do when you create the combo box in your resource editor is draw it like twice as tall as you really think it should look, the resourc editor automatically makes it back to the normal size again, but it stores the size bigger which gives it the space to allow for a list to be drawn. A little confusing I know, but you'll get it! :P The pressing the keys up and down just makes sure that you've added the strings properly. If you still can't get it to work, email me and I'll give you some more help (OR a code snippet) See ya, Ben
if u use a Dialogbox as Mainresource u can try it for example this way ... .if uMsg == WM_INITDIALOG invoke GetDlgItem,hWin,IDC_COMBO mov hCmbo,eax jmp labeladd coText1 db "Test1",0 coText2 db "Test2",0 coText3 db "Test3",0 coText4 db "Test4",0 labeladd: invoke SendMessage,hCmbo,CB_ADDSTRING,0,ADDR coText1 invoke SendMessage,hCmbo,CB_ADDSTRING,0,ADDR coText2 invoke SendMessage,hCmbo,CB_ADDSTRING,0,ADDR coText3 invoke SendMessage,hCmbo,CB_ADDSTRING,0,ADDR coText4 and thatīs it u have added 4 Strings to ur combo
Hi guys and thanks for the replies but for some reason it still doesn't work. .code start: invoke InitCommonControls WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR, CmdShow:DWORD WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .IF uMsg==WM_INITDIALOG invoke GetDlgItem, hWnd, IDC_COMBOPROD mov hProd, eax invoke GetDlgItem, hWnd, IDC_COMBOLANG mov hLang, eax invoke SendMessage,hProd,CB_ADDSTRING,0, addr sText1 invoke SendMessage,hLang,CB_ADDSTRING,0, addr sText2 For some reason my WM_INITDIALOG is never called so none of the above executes. I put the above lines under WM_CREATE but the GetDlgItem API returns 0 in EAX so nothing happens then either. I used Borland resource editor to make my comboboxes and they are are drop-down list and NOT owner-drawn, I did tried making them owner-drawn fixed and variable with and with out "Has String" setting but it doesn't work in any of the cases. Any ideas ? goatass
Looks like you're trying to mix two different techniques. If you create a window with CreateWindowEx, you must CreateWindowEx a combobox as a child of the window it will be embedded in. The most convenient time is when you get a WM_CREATE message. If you are using a resource editor to position a combobox in a window, then you are creating a dialog box. If you want to use this dialog box as your main window, check out Iczelion's tutorial #10.
ub1, thanks for the reply but I looked at that tut and I still can't get it to work. Could you please provide an example for me to look at where you would create and use a combo-box on a dialog box I would really appreciate it. Thaks goatass
The second example shows a very easy way to use a dialog box as a main window. It uses DialogBoxParam, and a very short "main" function. You must replace the window proc with a dialog proc. There are some important differences between a window proc and a dialog proc. To change a window proc into a dialog proc: 1) Eliminate the call to DefWindowProc. The default message handling is to return zero in EAX. .ELSE xor eax,eax ret 2) For each message you handle, return nonzero (e.g., 1) in EAX, instead of zero. 3) Delete the call to PostQuitMessage. 4) Add a call to EndDialog. (This is only for "modal" dialogs created with DialogBoxParam.) .IF uMsg == WM_CLOSE invoke EndDialog,hWnd,0 mov eax,1 ret 5) Replace WM_CREATE with WM_INITDIALOG. After making the above changes, retry your WM_INITDIALOG code.
ub1, thanks a lot it works great now, I also rewrote my program to use CreateWindowEx and that works great aswell. Thanks for all the help goatass