Combo-Box problem

Started by
3 comments, last by demonkoryu 19 years, 8 months ago
Hi, I am trying to write my second game, a pong "clone", and I am running into trouble with standard windows controls. I have a modal options dialog with a ComboBox ctrl in it, where I insert the supported screen screen resolutions for the user to select. The problem: However the combobox contains reportedly 236 items, of which the first properly shows up, when I click the listbox to drop down no list pops up. I get a small line under the combobox, indicating that it is in fact somehow dropped down, but I don't get any further. The combobox is a created in a resource with the SORT and DROPDOWN_LISTBOX styles. The dialog procedure looks something like that:

int CALLBACK SettingsDialogProcedure( HWND hDlg, uint msg, WPARAM wP, LPARAM lP )
{
  switch ( msg ) {
   case WM_INITDIALOG:
     disp_resolution_list resolutions;
     resolutions = disp_query_resolutions();
     disp_resolution_list::iterator it = resolutions.begin(); 
     boost::format fmt( "%1%*%2%*%3%(%4%Hz)" );
     std::strstream strstrm;

     while ( it != resolutions.end() ) {
        disp_resolution& res = *it++;
        strstrm << fmt % res.width % res.height % res.bpp % res.frequency << '\0';
     ComboBox_AddString( GetDlgItem( hDlg, IDC_RESOLUTION ), strstrm.str() );
  }
   ComboBox_SetCurSel( GetDlgItem( hDlg, IDC_RESOLUTION ), 0 );
			CheckDlgButton( hDlg, IDC_FULLSCREEN, user_fullscreen );

   assert( ComboBox_GetCount( GetDlgItem( hDlg, IDC_RESOLUTION ) ) == resolutions.size() );

  return TRUE;
  }

  // commands
  case WM_COMMAND: {
    int msg = HIWORD( wP );	// message
    int id = LOWORD( wP );	// control id

    switch ( id ) {
      case IDOK: 
      case IDCANCEL:
         EndDialog( hDlg, id );
         break;
      default: return FALSE;
    }
  }
  return FALSE;
}
Any ideas?
Advertisement
btw, when i use streams, they don't terminate correctly.

Instead of writing
 strstrm << bla;

i have to write
 strstrm << bla << '\0';


I can't understand that.

Thermo

Not sure about the combo box problem, but instead of strstreams, I suggest you use stringstreams. They use std::strings rather than char arrays, which should take care of your problem, aside from being easier to use.

template<typename T>T fromstring(const std::basic_string<TCHAR>& s){	std::basic_istringstream<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR> > iss(s);	T x;	iss >> x;	if(!iss)		throw std::invalid_argument("Bad argument!");	return x;}template<typename T>std::basic_string<TCHAR> tostring(const T& x){	std::basic_ostringstream<TCHAR, std::char_traits<TCHAR>, std::allocator<TCHAR> > oss;	oss << x;	if(!oss)		throw std::invalid_argument("Bad argument!");	return oss.str();}


- Pete
Quote:Original post by Konfusius
Hi,

I am trying to write my second game, a pong "clone", and I am running into trouble with standard windows controls. I have a modal options dialog with a ComboBox ctrl in it, where I insert the supported screen screen resolutions for the user to select.
The problem: However the combobox contains reportedly 236 items, of which the first properly shows up, when I click the listbox to drop down no list pops up. I get a small line under the combobox, indicating that it is in fact somehow dropped down, but I don't get any further.

The combobox is a created in a resource with the SORT and DROPDOWN_LISTBOX styles.

Any ideas?


Yes, it's actually quite simple - when you create dropdown combo box in the resource editor, the default size for the dropdown list region is zero, which annoyingly makes it impossible to actually see any of the items in the list.

To fix it, go into the resource editor, click the dropdown button on the combo box. A sizing rectangle should appear, but the top and side bits will be greyed out - this represents the dropdown area. Use the bottom one to make the dropdown area larger.
Thanks!
You both helped me alot! My problems are gone.

Thermo

This topic is closed to new replies.

Advertisement