[Closed] Adding elements to a ComboBox
I use SendDlgItemMessage( HWND, IDC_COMBO, CB_ADDSTRING, 0 ,(lParam) (char *) “b” );
to add elements to my comboBox, but always is empty. Is there something wrong?
Hi,
Try using LONG cast :
SendDlgItemMessage(HWND, IDC_COMBO, CB_ADDSTRING, 0 , (LONG)"b");
Excuse me but I cannot test win32 code on the PC I am :).
Yanick, I get that one element appears in the combo, but only one. It happens when I enter the command
SendDlgItemMessage( hDlg , IDC_COMBO , CB_SETCURSEL , 0 ,0 );
and the full commands for the comboBox are:
SendDlgItemMessage( hDlg , IDC_COMBO , CB_RESETCONTENT , 0 ,0 ); //empty the combo
for (int i=0;i<8;i++)
SendDlgItemMessage( hDlg , IDC_COMBO , CB_ADDSTRING, 0 , (LPARAM) (char *) “A”);
SendDlgItemMessage( hDlg , IDC_COMBO , CB_SETCURSEL , 0 ,0 );
Hi Alex,
Maybe your problem comes from the resource (RC) :
I’ve set the ComboBox style to “Drop List”.
I’ve open the resource file and set “45” for the height of the ComboBox.
I think your code should run as expected.
Changed to droplist and nothing happens.
Opened RC file and found COMBOBOX but, where is height? There are 4 numbers. I supose that height is one of them, but which?
Despite of, thanks to you Yarick, you are helping me very much!
OK, the height is the last number.
The four numbers are : xpos ypos width height