最近急用MFC,初識,用到了一些,有感而言,高手勿笑。
1.error C2660: “CWnd::MessageBoxA” : 函數不接受 4 個參數 錯誤解決
1
void CSerialPortEx::ProcessErrorMessage(char *ErrorText)
2
{
3
char *Temp=new char[200];
4
LPVOID lpMsgBuf;
5
FormatMessage(
6
FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
7
NULL,
8
GetLastError(),
9
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), //Default language
10
(LPTSTR)&lpMsgBuf,
11
0,
12
NULL);
13
sprintf(Temp,
14
"WARNING:%s Failed with the following error:\n%s\nPort:%d\n",
15
(char *)ErrorText,
16
lpMsgBuf,
17
m_nPortNr);
18
MessageBox(NULL,
19
Temp,
20
"Application Error",
21
MB_ICONSTOP);
22
LocalFree(lpMsgBuf);
23
delete[] Temp;
24
}
25
四個參數的MessageBox()是API中定義的,而在MFC中被重新定義了,是只需要一個參數的MessageBox(""); 因此你在MFC中調用api的函數,要在前面加上::
《待續》
posted on 2009-11-15 20:19
deercoder 閱讀(655)
評論(0) 編輯 收藏 引用 所屬分類:
MFC