Original Post
🔒 Locked
Combo Boxes
Advertisement
quote:
Original post by dta1
How do you define the listbox items? (using MSDEV 6.0)
And how do you use them?
I want to change a value depending on what listbox choise you choose.
SendMessage(CB_ADDSTRING, ...) to add a string and other CB_XXX messages to do other cool stuff.
Capture CBN_XXX notification messages to keep track of changes in the combobox. Just go to MSDN and find out for yourself.
Hope this helps,
Crispy
UINT id = 8800;
WinMain(...)
{
...
UINT style = CBS_DROPDOWN | CBS_HASSTRINGS | WS_VISIBLE | WS_CHILD;
UINT styleEx = 0;
cbHandle = CreateWindowEx(styleEx, "combobox", "I am the caption", style, 100, 100, 80, 400, hWnd, (HMENU)id, hInstance, (LPVOID)NULL);
...
}
WndProc(...)
{
switch(uMsg)
{
case WM_COMMAND:
switch(HIWORD(wParam))
{
case CBN_SELCHANGE:
//check if it's our control
if(LOWORD(wParam) == id)
MessageBox(0, "SelChange", "Boo!", MB_OK | MB_ICONDRINKME);
return 0;
}
return 0;
}
return DefWndProcThingie(..);
}
There you have it - a not-so-definitely working implementation of the combobox control (untested).
Here's a link: link
NOTE: always make sure your combobox HEIGHT is equal to the height you want it to be when dropped down! Setting it to 12 or something will only show you the edit control and you'll end up breaking your head with why strings that are added to the combobox do not end up there.
Crispy
edit: CBN_SELCHANGE, not CBN_SELCHANGED
[edited by - crispy on August 4, 2002 11:58:53 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement