这个窗口为什么不响应任何操作,就指点
#include<windows.h>#include<stdio.h>
WNDCLASS wndclass;
HWND hwnd;
MSG Msg;
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow
)
{
typedef struct_WNDCLASS;
{
wndclass.style=CS_VREDRAW|CS_HREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=TEXT("HAHA");
}
RegisterClass(&wndclass);
hwnd=CreateWindow( TEXT("HAHA"),
TEXT("XIXI"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0));
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
};
return 0;
};
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
为什么创建出来后,什么操作都不响应,关掉还要用任务管理器
求指点啊求指点{:9_220:}
本帖最后由 freeparty 于 2015-5-9 17:35 编辑
#include<windows.h>
#include<stdio.h>
WNDCLASS wndclass;
HWND hwnd;
MSG Msg;
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow
)
{
typedef struct_WNDCLASS;
{
wndclass.style=CS_VREDRAW|CS_HREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=TEXT("HAHA");
}
RegisterClass(&wndclass);
hwnd=CreateWindow( TEXT("HAHA"),
TEXT("XIXI"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
};
return 0;
};
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,message,wParam,lParam);
} 楼主,,,
54.while(GetMessage(&Msg,NULL,0,0));
你加了 ;下面的 TranslateMessage(&Msg);
DispatchMessage(&Msg); 就执行不了了
把;去掉就好了 freeparty 发表于 2015-5-9 16:16
54.while(GetMessage(&Msg,NULL,0,0));
问题在后面有个 ; 迷雾少年 发表于 2015-5-9 16:50
54.while(GetMessage(&Msg,NULL,0,0));
根本没调试,所以没看到。 谢各位:loveliness:
页:
[1]