943,737 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 1746
  • C++ RSS
Apr 14th, 2009
0

TextBox Value

Expand Post »
Hi,

How can I show a long value returned from a function to a textbox on a dialog box.

Void CVideoDlg::OnBnClickedFrames()
{
m_AMC.get_FramesDrawn(); // retunrs long
}

I want to display the returned value in textbox as well as a messagebox.

I tried MessageBox(CString(m_AMC.get_FramesDrawn()));

But it didn't work out

anyone can help with that

thx
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gallian99 is offline Offline
77 posts
since Jan 2009
Apr 14th, 2009
0

Re: TextBox Value

you need to use CString's Format() method. It works exactly like printf().

C++ Syntax (Toggle Plain Text)
  1. CString txt;
  2. txt.Format("%d", m_AMC.get_FramesDrawn()));
  3. MessageBox(txt, MB_OK);
Last edited by Ancient Dragon; Apr 14th, 2009 at 10:32 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Apr 14th, 2009
0

Re: TextBox Value

Gives the following error: C2664:\void ATL::CStringT<baset type, string traits>::Format(const wchar_t*,...)': cannot convert parameter 1 from 'const char[3] to const wchar_t*
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gallian99 is offline Offline
77 posts
since Jan 2009
Apr 14th, 2009
0

Re: TextBox Value

you are compiling for UNICODE, so param1 should be
L"%d" to force the conversion of the string to wchar_t*. Or it might be preferable to use _TEXT("%d") so that you can turn off UNICODE if you want to and not have to change that line.
Last edited by Ancient Dragon; Apr 14th, 2009 at 11:35 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Apr 15th, 2009
0

Re: TextBox Value

Thanks man!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gallian99 is offline Offline
77 posts
since Jan 2009
Apr 15th, 2009
0

Re: TextBox Value

you need to use CString's Format() method. It works exactly like printf().

C++ Syntax (Toggle Plain Text)
  1. CString txt;
  2. txt.Format("%d", m_AMC.get_FramesDrawn()));
  3. MessageBox(txt, MB_OK);
Sorry One last thing..

How can I display the output value in an edit box?

thanks
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gallian99 is offline Offline
77 posts
since Jan 2009
Apr 15th, 2009
0

Re: TextBox Value

Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Detecting a mouse click in an area
Next Thread in C++ Forum Timeline: How can i use the defined functions into the forms?





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


Follow us on Twitter


© 2011 DaniWeb® LLC