最近急用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 阅读(649)
评论(0) 编辑 收藏 引用 所属分类:
MFC