954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

TextBox Value

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

gallian99
Junior Poster in Training
77 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

CString txt;
txt.Format("%d", m_AMC.get_FramesDrawn()));
MessageBox(txt, MB_OK);
Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

Gives the following error: C2664:\void ATL::CStringT::Format(const wchar_t*,...)': cannot convert parameter 1 from 'const char[3] to const wchar_t*

gallian99
Junior Poster in Training
77 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Ancient Dragon
Retired & Loving It
Team Colleague
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

Thanks man!

gallian99
Junior Poster in Training
77 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

CString txt;
txt.Format("%d", m_AMC.get_FramesDrawn()));
MessageBox(txt, MB_OK);


Sorry One last thing..

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

thanks

gallian99
Junior Poster in Training
77 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 
Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You