MFC GetDlgItemText
-
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
-
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
-
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: -
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.
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:
-
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 few sugestions: #1 Make shure you call
SetCurSel()
inOnInitDialog
of the property page, otherwise the string will be empty. #2 Make shure if id of your combobox is equalIDC_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. -
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_Combo.GetLBText(m_Combo.GetCurSel(),path);
-
A few sugestions: #1 Make shure you call
SetCurSel()
inOnInitDialog
of the property page, otherwise the string will be empty. #2 Make shure if id of your combobox is equalIDC_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.