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

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);

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*

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.

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.