Skip to main content
gamedev.net
🔒 Locked

Combo Boxes

Started by dta1 Aug 4, 2002 at 5:30 AM 2 replies 350+ views
Original Post
dta1
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.
Erase, rewind and improve
Crispy
Crispy
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

"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
dta1
dta1
Thanks, but a link would be appreciated.

And, I think the best would be to see an example app using a combo box if you would happen to know where to find one.

[edited by - dta1 on August 4, 2002 10:43:29 AM]
Erase, rewind and improve
Crispy
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]
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared

Topic Locked

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

Sign in to reply to this topic.