Adding entries to ComboBox created using DLGITEMTEMPLATE *
-
Hi, I have created a ComboBox using DLGITEMTEMPLATE * and now, I want to add entries to this combobox. I could not have managed to figure out how to do this. Could nay body please help me out. Regards, ATif Gul
-
Hi, I have created a ComboBox using DLGITEMTEMPLATE * and now, I want to add entries to this combobox. I could not have managed to figure out how to do this. Could nay body please help me out. Regards, ATif Gul
-
hi douglas, Thanks a lot for sending me the link. I tried to send message to the combobox but it is not working. Let me explainn the problem a bit more. I have a DLGTEMPLATE * dialog, using this structure I create a dialog. then I use CreateIndirect of CDialog to create this dialog in memory. I add different controls to this dialog and each control is DLGITEMTEMPLATE *. I create a DLGTEMPLATEITEM* combobox and create it in memory. Now, when I do CWnD::GetDlgItem(IDC_COMBOBOX) it returns NULL. Could you please tell me what I am doing wrong or what the problem is. I tried the following code HWND combo_box_handle = 0; combo_box_handle = GetDlgItem(COMBOBOX_ID); SendMessage(combo_box_handle, CB_ADDSTRING, 0,(LPARAM)"One"); Thanks and regards, Atif Gul Hashmi
-
hi douglas, Thanks a lot for sending me the link. I tried to send message to the combobox but it is not working. Let me explainn the problem a bit more. I have a DLGTEMPLATE * dialog, using this structure I create a dialog. then I use CreateIndirect of CDialog to create this dialog in memory. I add different controls to this dialog and each control is DLGITEMTEMPLATE *. I create a DLGTEMPLATEITEM* combobox and create it in memory. Now, when I do CWnD::GetDlgItem(IDC_COMBOBOX) it returns NULL. Could you please tell me what I am doing wrong or what the problem is. I tried the following code HWND combo_box_handle = 0; combo_box_handle = GetDlgItem(COMBOBOX_ID); SendMessage(combo_box_handle, CB_ADDSTRING, 0,(LPARAM)"One"); Thanks and regards, Atif Gul Hashmi
Your code to add the string is correct, however if you are adding items to your memory template after you have called CreateDialogIndirect, the new items will not be part of the dialog until you first close that dialog window and recall CreateDialogIndirect. The only way to add more control items to an existing dialog would be to use CreateWindow and specify the dialog as the hwnd parent.
-
Your code to add the string is correct, however if you are adding items to your memory template after you have called CreateDialogIndirect, the new items will not be part of the dialog until you first close that dialog window and recall CreateDialogIndirect. The only way to add more control items to an existing dialog would be to use CreateWindow and specify the dialog as the hwnd parent.
I am not sure if I quite understood what you are saying. Actaully I create the dialog using CreataIndirect which is the member of CDialog class. Secondly, the combobox that I created using the DLGITEMTEMPLATE * is displayed when I run the program but when I use GetDlgItem(IDC_COMBO) it returns NULL as if the combobox does not exits. So could you please tell me how can I add items to this combobox. Regards, Atif
-
I am not sure if I quite understood what you are saying. Actaully I create the dialog using CreataIndirect which is the member of CDialog class. Secondly, the combobox that I created using the DLGITEMTEMPLATE * is displayed when I run the program but when I use GetDlgItem(IDC_COMBO) it returns NULL as if the combobox does not exits. So could you please tell me how can I add items to this combobox. Regards, Atif
Atif, I sugguest you debug the program in conjunction with Spy++ and verify the combo box identifier. If the combox box is being displayed in the dialog then it will have a window handle and items can be added. With GetDlgItem returning null then either your IDC_ is incorrect or the window handle for the dialog is incorrect.