|
-
May 4th, 2010, 04:36 AM
#1
[MFC] lost trying to retrieve text from an editBox
Dear All,
I am struggling trying to understand how to retrieve text from an edit box. My view class has the following variables associated to an edit box and a static label:
CEdit inputEditBox;
CStatic flippedNameStaticVar;
I have also set a method associated to the text change in the edit box:
afx_msg void OnEnChangeInputeditbox();
Now, I would like to perform the "simple" task of showing the input provided in the edit box into the static label (flippedNameStatiVar).
Unfortunately I am lost..
I am using Visual Studio 2008 Professional and tried the following:
void CFlippedNameTreeView::OnEnChangeInputeditbox()
{
LPTSTR bufferStr = L"text displayed";
int bufferLenght = this->inputEditBox.GetWindowTextLengthW();
this->inputEditBox.GetWindowTextW(bufferStr,bufferLenght);
this->flippedNameStaticVar.SetWindowTextW(bufferStr);
}
Unfortunately the text that is displayed is "text displayed" and not the text typed by the user in the frame where the edit box is.
Even more, I am not able to access to the GetWindowText function which I read is sometimes used (the VS code helper doesn't show this as option and if I try to write it then there are compilation errors saying that is not defined).
I then tried to see wheter the buffer of the edit box text was equal to zero but it wasn't. I tried to display the content of the buffer but here again, I am struggling..
I added the following to the code above which I found in another forum:
CString ls;
ls.Format("%d",bufferLenght);
LPTSTR bL;
test = ls.GetBuffer(ls.GetLength);
this->flippedNameStaticVar.SetWindowTextW(bL);
but this time there are compilation errors:
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [3]' to 'const wchar_t *'
I am aware that I need to study more MFC but could anyone give me some insight on this?
Thanks a lot!
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
|