View Full Version : Adding elements to a ComboBox
eledh_telamion 12-20-2006, 11:14 AM 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?
|
|
ypuech
12-20-2006, 01:43 PM
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 :).
eledh_telamion
12-20-2006, 05:08 PM
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 );
ypuech
12-20-2006, 07:03 PM
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.
eledh_telamion
12-20-2006, 07:30 PM
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!
ypuech
12-20-2006, 07:51 PM
OK, the height is the last number.
The four numbers are : xpos ypos width height
eledh_telamion
12-20-2006, 08:04 PM
Thanks Yanick! Works!
CGTalk Moderation
12-20-2006, 08:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.