943,777 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1097
  • C++ RSS
Aug 31st, 2009
0

Need help for MFC editbox

Expand Post »
Hi,

I am using visual studio 2008, C++ MFc. I have create 2 edit box. I will let user key in at the editbox1. Then i will get line and paste what user have key in to editbox2. I want it to be something like hyper terminal format. That mean when user key in "how r u" in editbox1 then press 'enter', the program should automatic get "how r u" (what the user key in) and paste/copy/send it to editbox2. Hope that someone can help me out with this. So far i can only get the line from editbox1 and paste it to editbox 2 with the help of button and with some errors.


In the button function:
UpdateData(TRUE);
int nCurrentLine = m_command.LineFromChar(-1);
int lineLen = m_command.LineLength(nCurrentLine);
LPTSTR p = m_strCommand.GetBuffer(lineLen+1);
m_command.GetLine(nCurrentLine, p);
m_strCommand.ReleaseBuffer(lineLen);
CString abc = m_strCommand;
SetDlgItemText(IDC_EDIT2, abc);
UpdateData(TRUE);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicholasamh is offline Offline
10 posts
since Aug 2009
Aug 31st, 2009
0

Re: Need help for MFC editbox

You could possibly handle the WM_KILLFOCUS (or EN_KILLFOCUS or whatever) event of editbox1.
Last edited by jencas; Aug 31st, 2009 at 7:10 am.
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Sep 1st, 2009
0

Re: Need help for MFC editbox

Click to Expand / Collapse  Quote originally posted by jencas ...
You could possibly handle the WM_KILLFOCUS (or EN_KILLFOCUS or whatever) event of editbox1.
Thanks, I will try it out
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicholasamh is offline Offline
10 posts
since Aug 2009
Sep 2nd, 2009
0

Re: Need help for MFC editbox

nicolasahm, I would investigate the Dialog Data Exchange and Validation capability or DDX mechanism within the MFC. I think this may help you with what you want to do. This function is called to carry out the exchange of data between variables in the dialog and it's controls. Also I'm not sure exactly what you want to do but it sounds like you want to have the user press the <Enter> key to transfer the text from one dialog control to the other. The "Want Return" property of the dialog control set to "True" uses the <Enter> key as a return character insertion mechanism, otherwise it should effectively call the button function.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Vallnerik is offline Offline
4 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Error When Using zlib
Next Thread in C++ Forum Timeline: How do I create my own compiler directives?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC