Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help SetWindowText
#1
hey i've started my first c++ program and i need some help .

i'm doing a Mfc windows app and i've added a multiline edit control box then i rightclicked it and whent to add Variable then i added a cedit,control variable with the name edit_box now when i go to add some text it fail's on compile with..
Code:
error C2065: 'edit_box' : undeclared identifier

here is code

Code:
    if( opendlg.DoModal() == IDOK )    
    {
        CString m_strPathname = opendlg.GetPathName();

        edit_box.SetWindowText(m_strPathname);
    }

its my first time looking at a mfc app or c++ so it will be simple im just noob atm... xD please help if you can
Reply

#2
.....
Reply

#3
(11-16-2011, 12:00)n3utra1 Wrote: Its telling you what is wrong, edit_box isnt declared

o.0 orlly , so in my .h file i have
Code:
CEdit edit_box;
and in my .cpp file theres

Code:
void CRealingtringDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);

    DDX_Control(pDX, IDC_EDIT1, edit_box);
}

what else do i need to do Confused ?
Reply

#4
.....
Reply

#5
that was done when i used the class wizard, i feel so noob atm lol its like my first post here all over again.
Reply

#6
(11-16-2011, 12:59)rotceh_dnih Wrote: that was done when i used the class wizard, i feel so noob atm lol its like my first post here all over again.

Sure you included the header file with the .cpp file? #include "<file.h>"
can't help much after this as I'm ony phone lol
[Image: b_560_95_1.png]
Reply

#7
(11-16-2011, 13:17)Nukem Wrote:
(11-16-2011, 12:59)rotceh_dnih Wrote: that was done when i used the class wizard, i feel so noob atm lol its like my first post here all over again.

Sure you included the header file with the .cpp file? #include "<file.h>"
can't help much after this as I'm ony phone lol

lol cool as , and yea it is included so ikr Confused whats wrong
Reply

#8
GetDlgItem(IDC_EDIT1)->SetWindowText("O hi");

But you can just make a pointer to it:

CStatic* weeee = (CStatic*)GetDlgItem(IDC_EDIT1);



But the DDX_Control(pDX, IDC_EDIT1, edit_box);

Will also init 'edit_box'

so you should be able to do edit_box.SetWindowText("O hi");
Reply

#9
(11-16-2011, 23:43)TwoPumpChump Wrote: GetDlgItem(IDC_EDIT1)->SetWindowText("O hi");
But you can just make a pointer to it:
CStatic* weeee = (CStatic*)GetDlgItem(IDC_EDIT1);
But the DDX_Control(pDX, IDC_EDIT1, edit_box);
Will also init 'edit_box'
so you should be able to do edit_box.SetWindowText("O hi");

nice, thanks man i thought it should work , i ended up starting again and did the same things and low and behold it worked xD , on to new issues now lol Smile

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.