0

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

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Nick Evan
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);
0

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*

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.

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.