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. MFC GetDlgItemText

MFC GetDlgItemText

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
7 Posts 4 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.
  • M Offline
    M Offline
    missnazar
    wrote on last edited by
    #1

    Hey this is too simple and even I don't know why it isn't happening? I want the text in the combobox to be copied to the String variable. eg: CString path; GetDlgItemText(IDC_COMBO1,path); but path remains null. I have spent my half day to find the problem...(I know there will be some silly mistake )..Can any one help me out Drushti

    B A M 3 Replies Last reply
    0
    • M missnazar

      Hey this is too simple and even I don't know why it isn't happening? I want the text in the combobox to be copied to the String variable. eg: CString path; GetDlgItemText(IDC_COMBO1,path); but path remains null. I have spent my half day to find the problem...(I know there will be some silly mistake )..Can any one help me out Drushti

      B Offline
      B Offline
      BlackDice
      wrote on last edited by
      #2

      if you have a variable associated with your combo, do this: m_combo.GetWindowText(path); or if not, do this: GetDlgItem(IDC_COMBO1)->GetWindowText(path); [insert witty comment here] bdiamond :zzz:

      M 1 Reply Last reply
      0
      • B BlackDice

        if you have a variable associated with your combo, do this: m_combo.GetWindowText(path); or if not, do this: GetDlgItem(IDC_COMBO1)->GetWindowText(path); [insert witty comment here] bdiamond :zzz:

        M Offline
        M Offline
        missnazar
        wrote on last edited by
        #3

        Hey bdiamond, Thanx for your reply....but either of the options didn't worked.:( ...Let be more specific...The combobox is part of property page and the pushbutton is on the child form view,clicking which the text of the combobox should be fetched.

        B 1 Reply Last reply
        0
        • M missnazar

          Hey bdiamond, Thanx for your reply....but either of the options didn't worked.:( ...Let be more specific...The combobox is part of property page and the pushbutton is on the child form view,clicking which the text of the combobox should be fetched.

          B Offline
          B Offline
          BlackDice
          wrote on last edited by
          #4

          please be more specific. if combo is on the main form part of the property page, there might be a GetParent() function or something like that for the individual pages to call, so in your button's handler routine it would look something like this:

          void CSubForm::OnButton1()
          {
            CParentForm* pParent = (CParentForm*)GetParent();
            pParent->GetWindowText(path);
          }
          

          if not, make a different constructor for your page and send in a pointer to the parent when you construct it. Have a member variable of type CParentForm* (or whatever the name of the parent class is) to set it to. then in your button's click event:

          {
            m_pParent->GetWindowText(path);
          }
          

          I'm not sure if this is right for your because I'm still kinda confused as to the types of your classes and all that, but hopefully this will point you in the right direction. [insert witty comment here] bdiamond :zzz:

          1 Reply Last reply
          0
          • M missnazar

            Hey this is too simple and even I don't know why it isn't happening? I want the text in the combobox to be copied to the String variable. eg: CString path; GetDlgItemText(IDC_COMBO1,path); but path remains null. I have spent my half day to find the problem...(I know there will be some silly mistake )..Can any one help me out Drushti

            A Offline
            A Offline
            Andrzej Markowski
            wrote on last edited by
            #5

            A few sugestions: #1 Make shure you call SetCurSel() in OnInitDialog of the property page, otherwise the string will be empty. #2 Make shure if id of your combobox is equal IDC_COMBO1 and is not assigned to another control #3 If the combobox is placed on the property page, use this: pPropertySheet->GetPage(PageNo)->GetDlgWindowText(IDC_COMBO1,s). ***** A.M.

            M 1 Reply Last reply
            0
            • M missnazar

              Hey this is too simple and even I don't know why it isn't happening? I want the text in the combobox to be copied to the String variable. eg: CString path; GetDlgItemText(IDC_COMBO1,path); but path remains null. I have spent my half day to find the problem...(I know there will be some silly mistake )..Can any one help me out Drushti

              M Offline
              M Offline
              Max Santos
              wrote on last edited by
              #6

              m_Combo.GetLBText(m_Combo.GetCurSel(),path);

              1 Reply Last reply
              0
              • A Andrzej Markowski

                A few sugestions: #1 Make shure you call SetCurSel() in OnInitDialog of the property page, otherwise the string will be empty. #2 Make shure if id of your combobox is equal IDC_COMBO1 and is not assigned to another control #3 If the combobox is placed on the property page, use this: pPropertySheet->GetPage(PageNo)->GetDlgWindowText(IDC_COMBO1,s). ***** A.M.

                M Offline
                M Offline
                missnazar
                wrote on last edited by
                #7

                Thankyou Andrzej Markowski , your suggestion :- pPropertySheet->GetPage(PageNo)->GetDlgWindowText(IDC_COMBO1,s), worked with a minor change. pPropertySheet->GetPage(PageNo)->GetDlgItemText(IDC_COMBO1,s), Thanx once again :) Drushti

                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