Share via


CString::FormatMessage

void FormatMessage( LPCTSTR lpszFormat**, ... );**

void FormatMessage( UINT nFormatID**, ... );**

Parameters

lpszFormat

Points to the format-control string. It will be scanned for inserts and formatted accordingly. The format string is similar to run-time function -style format strings, except it allows for the parameters to be inserted in an arbitrary order.

nFormatID

The string resource identifier that contains the unformatted message text.

Remarks

Call 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 function in the Win32 SDK Programmer’s Reference.

Example

CString 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!"));

CString OverviewClass MembersHierarchy Chart

See Also   , CString::LoadString, CString::Format