VC++程序运行后无窗口出现
程序编译通过,在进程中也可以看到,但就是没有运行窗口弹出!请高手指点,windows刚刚学习程序代码如下:#include<windows.h>LRESULTCALLBA...
程序编译通过,在进程中也可以看到,但就是没有运行窗口弹出!请高手指点,windows刚刚学习
程序代码如下:
#include <windows.h>
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wnd;
HWND hwnd=NULL;
MSG msg;
//1.设计窗口类
wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hbrBackground=(HBRUSH)(COLOR_WINDOW);
wnd.hCursor=LoadCursor(NULL,IDC_ICON);
wnd.hIcon=LoadIcon(NULL,IDI_ERROR);
wnd.hInstance=hInstance;
wnd.lpfnWndProc=WndProc;
wnd.lpszClassName="MyFirstWindow";
wnd.lpszMenuName=NULL;
wnd.style=CS_HREDRAW|CS_VREDRAW;
//2.注册窗口类型
RegisterClass(&wnd);
//3.创建窗口
hwnd=CreateWindow("WndClass", "window窗口创建", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
//4.显示及更新窗口
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
} 展开
程序代码如下:
#include <windows.h>
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS wnd;
HWND hwnd=NULL;
MSG msg;
//1.设计窗口类
wnd.cbClsExtra=0;
wnd.cbWndExtra=0;
wnd.hbrBackground=(HBRUSH)(COLOR_WINDOW);
wnd.hCursor=LoadCursor(NULL,IDC_ICON);
wnd.hIcon=LoadIcon(NULL,IDI_ERROR);
wnd.hInstance=hInstance;
wnd.lpfnWndProc=WndProc;
wnd.lpszClassName="MyFirstWindow";
wnd.lpszMenuName=NULL;
wnd.style=CS_HREDRAW|CS_VREDRAW;
//2.注册窗口类型
RegisterClass(&wnd);
//3.创建窗口
hwnd=CreateWindow("WndClass", "window窗口创建", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
//4.显示及更新窗口
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询