doubt in textbox controls used in MFC
-
Hai, Good Evening.... I was working with the controls of textbox i have a doubt in that can anyone clear it.... I created a form in MFC by having various controls. 1.In that i have a textbox in which iam entering some values. 2.I want that value to be printed in the message box... Can anyone please tell me how to do.... Thanks Harshadha
You have a editbox
CEdit m_EDit;
and it has values "12345" now you want to show these values use ofm_Edit1.GetWindowText();
WhiteSky
-
You have a editbox
CEdit m_EDit;
and it has values "12345" now you want to show these values use ofm_Edit1.GetWindowText();
WhiteSky
-
hai, i cant understand .. Iam passing values to the editbox in run time ,then if i click a command button iam displaying a messagebox,where i want these value to be shown... Harshadha
-
Hai, Good Evening.... I was working with the controls of textbox i have a doubt in that can anyone clear it.... I created a form in MFC by having various controls. 1.In that i have a textbox in which iam entering some values. 2.I want that value to be printed in the message box... Can anyone please tell me how to do.... Thanks Harshadha
Use
WM_KILLFOCUS
for your text box and get the text usingGetWindowText
. I hope this is you want. -
hai, i cant understand .. Iam passing values to the editbox in run time ,then if i click a command button iam displaying a messagebox,where i want these value to be shown... Harshadha
When click button use of
CEdit m_Edit;
CString str;
m_Edit.GetWindowText(str);
MessageBox(str);And if you want to set a value dynamicly for editbox use of
SetWindowText
WhiteSky
-
Use
WM_KILLFOCUS
for your text box and get the text usingGetWindowText
. I hope this is you want.Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha
-
Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha
int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const; void GetWindowText( CString& rString ) const;
Use as belowCEdit m_ce; CString str; m_ce.GetWindowText(str); TCHAR szMsg[256]; long lValue = _ttol((LPCTSTR)str); wsprintf(szMsg,_T("hEIGHT: %ld "),lValue); MessageBox(szMsg,NULL,MB_OK);
-- modified at 6:26 Thursday 8th March, 2007 -
Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha
I wrote for you an exmaple and also GetWindowText needs to a parameter for hold values
WhiteSky
-
int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const; void GetWindowText( CString& rString ) const;
Use as belowCEdit m_ce; CString str; m_ce.GetWindowText(str); TCHAR szMsg[256]; long lValue = _ttol((LPCTSTR)str); wsprintf(szMsg,_T("hEIGHT: %ld "),lValue); MessageBox(szMsg,NULL,MB_OK);
-- modified at 6:26 Thursday 8th March, 2007 -
Hai, Iam sorry for troubling you again but iam getting memory error like asking whether to retry or abort... If i click ignore its displaying msgbox with 0 in it.. Thanks Harshadha
have you done validation on the text box like the input is only numeric value and not alphabet nor alphanumeric...
-
have you done validation on the text box like the input is only numeric value and not alphabet nor alphanumeric...
-
Hai, Iam sorry for troubling you again but iam getting memory error like asking whether to retry or abort... If i click ignore its displaying msgbox with 0 in it.. Thanks Harshadha
Hi, I think u havent created a member variable for the editbox. Simply you would have written like CEdit m_ce; It ll not work out. First you need to create a member variable for the edit box using class wizard with the control type as Edit. say, the member variable is m_editChar. then, CString str; m_editChar.GetWindowText(str); MessageBox(str); now, the str ll give u the value entered by the user in the edit box. Hope this ll solve your problem.
Thanks & Rgds, Sri..
-
Hi, I think u havent created a member variable for the editbox. Simply you would have written like CEdit m_ce; It ll not work out. First you need to create a member variable for the edit box using class wizard with the control type as Edit. say, the member variable is m_editChar. then, CString str; m_editChar.GetWindowText(str); MessageBox(str); now, the str ll give u the value entered by the user in the edit box. Hope this ll solve your problem.
Thanks & Rgds, Sri..
-
Hai, Good Evening.... I was working with the controls of textbox i have a doubt in that can anyone clear it.... I created a form in MFC by having various controls. 1.In that i have a textbox in which iam entering some values. 2.I want that value to be printed in the message box... Can anyone please tell me how to do.... Thanks Harshadha
-
Hai,, I cant really understand i brief my question.. Iam entering the values in edit box during runtime and displaying it... CEdit m_ce; m_ce.GetWindowText(); TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce); MessageBox(szMsg,NULL,MB_OK); error C2661: 'GetWindowTextA' : no overloaded function takes 0 parameters Thanks For Spending Your Precious Time Harshadha
harshadha wrote:
TCHAR szMsg[256]; wsprintf(szMsg,_T("hEIGHT: %ld "),m_ce);
So then why are not using
CString
with your MFC application?harshadha wrote:
MessageBox(szMsg,NULL,MB_OK);
Consider using
AfxMessageBox()
.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
I hope you got your answer with best way ;)
WhiteSky