ExampleCString str;
int nAsked = 5;
int nAgree = 4;str.FormatMessage(_T("%1!d! of %2!d! developers agree: Hockey is %3%!"),
nAgree, nAsked, _T("Best"));
ASSERT(str == _T("4 of 5 developers agree: Hockey is Best!"));上面这小段代码是摘至MSDN里的,有一点我不明白,就是为什么会是
%1!%d!
%2!%d!
%3!%!
呢?加上!这个是什么意思呢?以前看格式化字符串时,也不是这样的啊
int nAsked = 5;
int nAgree = 4;str.FormatMessage(_T("%1!d! of %2!d! developers agree: Hockey is %3%!"),
nAgree, nAsked, _T("Best"));
ASSERT(str == _T("4 of 5 developers agree: Hockey is Best!"));上面这小段代码是摘至MSDN里的,有一点我不明白,就是为什么会是
%1!%d!
%2!%d!
%3!%!
呢?加上!这个是什么意思呢?以前看格式化字符串时,也不是这样的啊
解决方案 »
- 如果添加位图?
- 如何将.h文件编译成.lib文件?
- combo list中添加项目顺序
- 为什么调用_ConnectPtr::Release()导致程序长期阻塞呢?奇怪
- 请问VC里,RC文件中的资源大小是以什么为单位的?
- 请教!
- 在CListCtrl中选中一项对应的消息响应函数OnItemclickList中,什么参数表示选中项的信息?
- Formview上的Edit控件为什么不能使用Ctrl+C及Ctrl+V分别做粘贴和拷贝
- CCheckListBox类的消息映射问题
- COM组件中的一个对话框中含有ActiveX控件,在MFC中使用此组件弹出对话框时程序崩溃?
- 再抛出100分:有谁知道怎么在VC中使用浏览PDF文件?
- 动态数组
CString::FormatMessage
void FormatMessage( LPCTSTR lpszFormat, ... );void FormatMessage( UINT nFormatID, ... );ParameterslpszFormatPoints to the format-control string. It will be scanned for inserts and formatted accordingly. The format string is similar to run-time functionprintf-style format strings, except it allows for the parameters to be inserted in an arbitrary order.nFormatIDThe string resource identifier that contains the unformatted message text.ResCall this member function to format a message string. The function requires a message definition as input. The message definition is determined by lpszFormat or from the string resource identified by nFormatID. The function copies the formatted message text to the CString, processing any embedded insert sequences if requested.Each insert must have a corresponding parameter following the lpszFormat or nFormatID parameter. Within the message text, several escape sequences are supported for dynamically formatting the message. For a description of these escape sequences and their meanings, see the Windows::FormatMessage function in the Win32 SDK Programmer’s Reference.
跟我上面的合起来不就是下面的吗CString::FormatMessage
void FormatMessage( LPCTSTR lpszFormat, ... );void FormatMessage( UINT nFormatID, ... );ParameterslpszFormatPoints to the format-control string. It will be scanned for inserts and formatted accordingly. The format string is similar to run-time functionprintf-style format strings, except it allows for the parameters to be inserted in an arbitrary order.nFormatIDThe string resource identifier that contains the unformatted message text.ResCall this member function to format a message string. The function requires a message definition as input. The message definition is determined by lpszFormat or from the string resource identified by nFormatID. The function copies the formatted message text to the CString, processing any embedded insert sequences if requested.Each insert must have a corresponding parameter following the lpszFormat or nFormatID parameter. Within the message text, several escape sequences are supported for dynamically formatting the message. For a description of these escape sequences and their meanings, see the Windows::FormatMessage function in the Win32 SDK Programmer’s Reference.ExampleCString str;
int nAsked = 5;
int nAgree = 4;str.FormatMessage(_T("%1!d! of %2!d! developers agree: Hockey is %3%!"),
nAgree, nAsked, _T("Best"));
ASSERT(str == _T("4 of 5 developers agree: Hockey is Best!"));
不过好像找不到 Windows::FormatMessage 函数啊