Jump to content
  • Advertisement
Sign in to follow this  
The C modest god

Combo box

This topic is 5042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
If you're using Win32, look up the CB_xxx messages.

CB_ADDSTRING will add an item to the list.

With CB_GETCURSEL you get the currently selected item.

If the Combo is editable you'd better use GetWindowText() to get the current item.

If MFC, it's AddString, and GetCurSel as member of the CComboBox class.

Share this post


Link to post
Share on other sites
Ok, I have done the following:

DialogBox ( hThisInstance, ( LPCTSTR ) IDD_GRAPHICS, hWnd, ( DLGPROC ) MainWndProcGraphicsSetup );
PostMessage (hWnd, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"Normal");
PostMessage (hWnd, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"Hard");

It doesnt show these options I have added to the dialog box.
Perhaps I need an hWnd of the dialog box? how do I get the hWnd of the dialog box, if it has one...

Share this post


Link to post
Share on other sites
Quote:
Original post by The C modest god
Ok, I have done the following:

DialogBox ( hThisInstance, ( LPCTSTR ) IDD_GRAPHICS, hWnd, ( DLGPROC ) MainWndProcGraphicsSetup );
PostMessage (hWnd, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"Normal");
PostMessage (hWnd, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"Hard");



It doesnt show these options I have added to the dialog box.
Perhaps I need an hWnd of the dialog box? how do I get the hWnd of the dialog box, if it has one...


The problem with that snippet is that after DialogBox is finished, the dialog is gone already.

Put the CB_ADDSTRINGs in the MainWndProcGraphicsSetup when you get WM_INITDIALOG. And as Paradigm Shifter said, at that position use GetDlgItem to get the HWND of the combo box.

Sample code (inside MainWndProcGraphicsSetup ):


....
case WM_INITDIALOG:
{
HWND hwndComboBox = GetDlgItem( hWnd, ID_OF_COMBOBOX );

SendMessage( hwndComboBox, CB_ADDSTRING, 0, (LPARAM)"Normal" );
SendMessage( hwndComboBox, CB_ADDSTRING, 0, (LPARAM)"Hard" );

}
return TRUE;

Share this post


Link to post
Share on other sites
Still doesnt work, here is what I am doing:

BOOL CALLBACK MainWndProcGraphicsSetup ( HWND Window, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
HWND hwndComboBox;
switch ( uMsg ) {
case WM_INITDIALOG:
hwndComboBox = GetDlgItem( Window, IDC_COMBO1 );

SendMessage (hwndComboBox, CB_ADDSTRING, 0, (LPARAM)"Anti aliased (slower)");
SendMessage (hwndComboBox, CB_ADDSTRING, 0, (LPARAM)"Aliased (faster)");
return TRUE;

Share this post


Link to post
Share on other sites
Which styles does the combo have? (Dropdown-List?)

Did you set the popup-height of the combo in the resource editor?
(In the editor, click on the down-button of the combobox; the selection rectangle should change appearance, adjust the height of the popup list here)

Also, per default nothing is being selected. The added items will only appear in the dropdown list. You can do that by sending CB_SETCURSEL.

Share this post


Link to post
Share on other sites
Quote:
Original post by Endurion
Did you set the popup-height of the combo in the resource editor?

*g* that bitten me too, combos are shy maidens :)

Thermo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!