这几天刚学着写MFC...今天准备写个Hello World 小程序试试手.... 出现了这样一个错误....--------------------Configuration: WinMain_Text - Win32 Debug--------------------
Compiling...
WinMain_Text.cpp
F:\练习\WinMain_Text.cpp(17) : error C2731: 'WinMain' : function cannot be overloaded
F:\练习\WinMain_Text.cpp(11) : see declaration of 'WinMain'
Error executing cl.exe.WinMain_Text.exe - 1 error(s), 0 warning(s)*****************************************************
函数体如下:int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wndclass; wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WinProc; //调用的函数
wndclass.lpszClassName = "Test";
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndclass); HWND hwnd;
hwnd = CreateWindow("Text","Hello World!",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWDEFAULT);
UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}//end while return 0;}//end WinMain还望达人解释下....谢谢!
Compiling...
WinMain_Text.cpp
F:\练习\WinMain_Text.cpp(17) : error C2731: 'WinMain' : function cannot be overloaded
F:\练习\WinMain_Text.cpp(11) : see declaration of 'WinMain'
Error executing cl.exe.WinMain_Text.exe - 1 error(s), 0 warning(s)*****************************************************
函数体如下:int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wndclass; wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hInstance = hInstance;
wndclass.lpfnWndProc = WinProc; //调用的函数
wndclass.lpszClassName = "Test";
wndclass.lpszMenuName = NULL;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndclass); HWND hwnd;
hwnd = CreateWindow("Text","Hello World!",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWDEFAULT);
UpdateWindow(hwnd); MSG msg; while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}//end while return 0;}//end WinMain还望达人解释下....谢谢!
解决方案 »
- 看看我的这个def文件错在哪里
- 急问:对话框中的按键在运行的时候没有全部显示出来 只显示了ok和cancel 这是什么回事?
- error C2248 cannot access private member declared in class
- mixerOpen 中用不同Flag(最后一个参数)打开设备,从而来设置系统麦克风的音量有什么区别?
- 问一sql语句(mysql)
- 怎么算出两个日期中包含了多少个周六和周日?急急,谢谢
- 设置系统默认浏览器的问题,我要疯了……
- 对话框上有个取消按钮,我一按取消界面就没有了,其实我要实现的按下取消内部不保存到文件
- 有做过photoshop滤镜的吗?
- 在发消息的时候,如果我要传递一个结构过去,怎么处理?
- 想在网络编程方面深入学习一下, 大家推荐一些好书
- 关于调试运行的问题
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return int(msg.wParam);
这条行的,但是不知道原理,可否请教一下?
可以找一本孙鑫老师的《vc++深入详解》看看
上面讲的 很清楚
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)Win32程序WinMain原型