|
-
June 21st, 2004, 02:05 AM
#1
Edit Box
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?
-
June 21st, 2004, 02:27 AM
#2
write this in OnButton1Click()
{
CString str;
edit1.GetWindowText(str);
edit2.SetWindowText(str);
}
NULL Pointer to intelligence
-
June 21st, 2004, 02:31 AM
#3
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...
-
June 21st, 2004, 02:39 AM
#4
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
-
June 21st, 2004, 02:43 AM
#5
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...
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
-
June 21st, 2004, 02:43 AM
#6
You must associate your edit controls with variables edit1 and edit2. Use classwizard for this.
-
June 21st, 2004, 02:47 AM
#7
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
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
-
June 21st, 2004, 02:54 AM
#8
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
thanks!! I got it ...
really indeed a great help.
-
June 21st, 2004, 02:55 AM
#9
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
if you want to use this code
EDIT1 and edit2 have to be member variables of category control type CEdit
there are 10 kinds of people. those who understand binary and those who don't...
rate a post if you find it usefull, thx
check out my Firefox/Mozilla Extension: http://urlparams.blogwart.com/
-
June 21st, 2004, 03:01 AM
#10
so if i wan to vice-verse sending to each other ie: edit1 and edit2
so how do i code it??
-
June 21st, 2004, 06:08 AM
#11
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
Well...one correction...never mix the standard type 'bool' with the Microsoft define 'BOOL'...thus...
Code:
UpdateData(TRUE); //writes text in editboxes to memebr vars
m_ctrlEdit2 = m_ctrlEdit1;
UpdateData(FALSE); //write text in member vars to edit boxes
-
June 21st, 2004, 07:45 AM
#12
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
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|