Outputting variables in a MessageBox
-
Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf:
printf("Hello! Your are customer number %d \n", CustomerNumber);
That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya
-
Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf:
printf("Hello! Your are customer number %d \n", CustomerNumber);
That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya
Use
CString
and theFormat()
method:CString str;
str.Format(_T("Hello! You are customer number: %d"), CustomerNumber);
AfxMessageBox(str);--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Use
CString
and theFormat()
method:CString str;
str.Format(_T("Hello! You are customer number: %d"), CustomerNumber);
AfxMessageBox(str);--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Thanks a lot Mike. :)
Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya
-
Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf:
printf("Hello! Your are customer number %d \n", CustomerNumber);
That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya
In addition to Michael's suggestion, there's also
AfxFormatString1()
.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Hi. I was wondering if MFC supplies a MessageBox kind of thing where the output can be formatted. Some thing like the good old printf:
printf("Hello! Your are customer number %d \n", CustomerNumber);
That would make it possible for me to output my variables to messagebox. Any other way is also cool, except the one with having to write my own custom window. :(Abhishek It is impossible to change your past. But it is very possible to ruin your present by worring about the future. -Chankya
I would use the TRACE macro to output variable in the output window in the DEBUG mode, instead of using message box.
Maximilien Lincourt Your Head A Splode - Strong Bad