Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Adding entries to ComboBox created using DLGITEMTEMPLATE *

Adding entries to ComboBox created using DLGITEMTEMPLATE *

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Atif Hashmi
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • A Atif Hashmi

      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

      D Offline
      D Offline
      douglasjordan
      wrote on last edited by
      #2

      see this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxes.asp[^]

      A 1 Reply Last reply
      0
      • D douglasjordan

        see this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/comboboxes/comboboxes.asp[^]

        A Offline
        A Offline
        Atif Hashmi
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • A Atif 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

          D Offline
          D Offline
          douglasjordan
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • D douglasjordan

            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.

            A Offline
            A Offline
            Atif Hashmi
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • A Atif Hashmi

              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

              D Offline
              D Offline
              douglasjordan
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups