Re: INCREDIBLE MessageBox
I would be more inclined to use a string like:
_T("The result is %1!d!")
and use FormatMessage. If you get used to using FormatMessage you can
localize a lot easier since the tokens are move-able within the string.
Since there is only one here it's not such a big deal, but with something
like:
_T("The result is %1!d! %2") where the user would fill in something like:
"The result is 10 widgets" it might be in a different order in a different
language. So, I pretty much just use FormatMessage() wherever I can. You
can also do something in the form of:
msg.FormatMessage(IDS_RESULT_FORMAT, a)
as well. The caveat, of course, is that floating point is not supported, so
I usually just format those numbers into strings first then use that string.
http://msdn2.microsoft.com/en-us/library/041zd9kb(VS.80).aspx
I know you know all this Joe (I think you even wrote an article about it),
I'm just tacking on to your message to do my little soapbox thing :o)
Tom
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:ribtd3pei8mpaop4fnt46nmvk3gbbfqqt1@4ax.com...
You can't; it doesn't even make sense to do so. What you NEED to do is
convert it to a
string, which is a different question.
CString msg;
msg.Format(_T("The result is %d"), a);
AfxMessageBox(msg, ...);
You should not be writing raw MessageBox calls, either. Use
AfxMessageBox.
Better still, do what I do:
CString fmt;
fmt.LoadString(IDS_RESULT_FORMAT);
CString msg;
msg.Format(fmt, a);
AfxMessageBox(msg, ...);
you should not have a native-language string anywhere in your code. If
you have a word as
a quoted string and it applies to only one language, you should use either
a STRINGTABLE
or a MESSAGETABLE resource to handle it.
joe
On Mon, 3 Sep 2007 14:20:01 -0700, marcomb
<marcomb@discussions.microsoft.com> wrote:
Another questio...how can i cast an int value to LPCTSTR so that a
MessageBox
can display it?
I think..
int a = 10;
MessageBox(LPCTSTR(a),...);
Doesn't works...
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm