問題描述
AfxMessageBox("Failed to connect to server\nTry again?",MB_YESNO)
出現問題:no instance of overloaded function "AfxMessageBox" matches the argument list
解決方案
添加 L 如下
AfxMessageBox( L"Failed to connect to server\nTry again?",MB_YESNO)
究其原因是“字元集”的問題,改“使用 Unicode 字元集”為 “使用多位元組字元集” AfxMessageBox("Failed to connect to server\nTry again?",MB_YESNO) 不添加 L 也 可以。
int AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0
);
Parameters
- lpszText
- Points to a CString object or null-terminated string containing the message to be displayed in the message box. nType
- The style of the message box. Apply any of the message-box styles to the box. nIDHelp
- The Help context ID for the message; 0 indicates the application's default Help context will be used.
-
Remarks
The first form of this overloaded function displays a text string pointed to by lpszText in the message box and uses nIDHelp to describe a Help context. The Help context is used to jump to an associated Help topic when the user presses the Help key (typically F1).Example
// A simple message box, with only the OK button. AfxMessageBox("Simple message box."); // A message box that uses a string from a string table // with yes and no buttons and the stop icon. // NOTE: nStringID is an integer that contains a valid id of // a string in the current resource. AfxMessageBox(nStringID, MB_YESNO|MB_ICONSTOP);