hi guys,
need help...
I would like to type a string of data in edit box1.
and display in edit box2 after i press a "button".
how do i code it?
Printable View
hi guys,
need help...
I would like to type a string of data in edit box1.
and display in edit box2 after i press a "button".
how do i code it?
write this in OnButton1Click()
{
CString str;
edit1.GetWindowText(str);
edit2.SetWindowText(str);
}
Add a message handler for the button 'OnClick' message. Inside it, get the data from the first edit control and put it into the second one...
u mean like this
void CSerialcommDlg::Onsend()
{
CString str;
EDIT1.GetWindowText(str);
edit2.SetWindowText(str);
}
but i got this error:
C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2065: 'EDIT1' : undeclared identifier
C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2228: left of '.GetWindowTextA' must have class/struct/union type
C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2065: 'edit2' : undeclared identifier
C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2228: left of '.SetWindowTextA' must have class/struct/union type
wat u mean by adding a message handler for the button??Quote:
Originally posted by Andreas Masur
Add a message handler for the button 'OnClick' message. Inside it, get the data from the first edit control and put it into the second one...
i dun really get it ..
can u pls teach me how to do it. thanks
You must associate your edit controls with variables edit1 and edit2. Use classwizard for this.
take this approach:
open your Dialog template, CTRL+W, tab member variables and add member vars (category value, type CString) for your edit boxes
lets say m_ctrlEdit1 and m_ctrlEdit2
in OnSend:
Code:UpdateData(true); //writes text in editboxes to memebr vars
m_ctrlEdit2 = m_ctrlEdit1;
UpdateData(false); //write text in member vars to edit boxes
thanks!! I got it ...Quote:
Originally posted by bigBA
take this approach:
open your Dialog template, CTRL+W, tab member variables and add member vars (category value, type CString) for your edit boxes
lets say m_ctrlEdit1 and m_ctrlEdit2
in OnSend:
Code:UpdateData(true); //writes text in editboxes to memebr vars
m_ctrlEdit2 = m_ctrlEdit1;
UpdateData(false); //write text in member vars to edit boxes
really indeed a great help.
if you want to use this codeQuote:
Originally posted by larry77
u mean like this
void CSerialcommDlg::Onsend()
{
CString str;
EDIT1.GetWindowText(str);
edit2.SetWindowText(str);
}
but i got this error:
C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2065: 'EDIT1' : undeclared identifier
C:\Testing Area\serialcomm\serialcommDlg.cpp(190) : error C2228: left of '.GetWindowTextA' must have class/struct/union type
C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2065: 'edit2' : undeclared identifier
C:\Testing Area\serialcomm\serialcommDlg.cpp(191) : error C2228: left of '.SetWindowTextA' must have class/struct/union type
EDIT1 and edit2 have to be member variables of category control type CEdit
so if i wan to vice-verse sending to each other ie: edit1 and edit2
so how do i code it??
Well...one correction...never mix the standard type 'bool' with the Microsoft define 'BOOL'...thus...Quote:
Originally posted by bigBA
in OnSend:
Code:UpdateData(true); //writes text in editboxes to memebr vars
m_ctrlEdit2 = m_ctrlEdit1;
UpdateData(false); //write text in member vars to edit boxes
Code:UpdateData(TRUE); //writes text in editboxes to memebr vars
m_ctrlEdit2 = m_ctrlEdit1;
UpdateData(FALSE); //write text in member vars to edit boxes
My suggestion to you if you have to ask this question, is to get a good tutorial book on programming with MFC and work through it. I don't mean to this sound condecending, but What you're asking is rudimentary MFC coding. It sound like you may be a little ahead of yourself at this point. Work through a tutorial to get a handle on the basics, then some of this stuff will make sense. Untill you do that, I'm not sure any answers you recieve here will make sense to you.Quote:
Originally posted by larry77
wat u mean by adding a message handler for the button??
i dun really get it ..
can u pls teach me how to do it. thanks