TextBox Value

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jan 2009
Posts: 68
Reputation: gallian99 is an unknown quantity at this point 
Solved Threads: 0
gallian99 gallian99 is offline Offline
Junior Poster in Training

TextBox Value

 
0
  #1
Apr 14th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,440
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1473
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: TextBox Value

 
0
  #2
Apr 14th, 2009
you need to use CString's Format() method. It works exactly like printf().

  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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: gallian99 is an unknown quantity at this point 
Solved Threads: 0
gallian99 gallian99 is offline Offline
Junior Poster in Training

Re: TextBox Value

 
0
  #3
Apr 14th, 2009
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*
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,440
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1473
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: TextBox Value

 
0
  #4
Apr 14th, 2009
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: gallian99 is an unknown quantity at this point 
Solved Threads: 0
gallian99 gallian99 is offline Offline
Junior Poster in Training

Re: TextBox Value

 
0
  #5
Apr 15th, 2009
Thanks man!
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 68
Reputation: gallian99 is an unknown quantity at this point 
Solved Threads: 0
gallian99 gallian99 is offline Offline
Junior Poster in Training

Re: TextBox Value

 
0
  #6
Apr 15th, 2009
Originally Posted by Ancient Dragon View Post
you need to use CString's Format() method. It works exactly like printf().

  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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,878
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: TextBox Value

 
0
  #7
Apr 15th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC