哎 大家帮忙看下 win编程初学者用api产生窗口的那个例子 哪错了?
#include<windows.h>LRESULTCALLBACKwndproc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(H...
#include<windows.h>
LRESULT CALLBACK wndproc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hins,HINSTANCE hinspre,LPSTR ncmdline,int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hwnd=NULL;
char name[10]="wndcls";
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc=wndproc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.lpszClassName=name;
wc.hInstance=hins;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.lpszMenuName=NULL;
RegisterClass(&wc);
hwnd=CreateWindow(name,"test window",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,
NULL,NULL,NULL,NULL);
if(hwnd==NULL)
{
MessageBox(NULL,"create failed..","error",MB_OK);
return 0;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK wndproc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_QUIT:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
} 展开
LRESULT CALLBACK wndproc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hins,HINSTANCE hinspre,LPSTR ncmdline,int nCmdShow)
{
WNDCLASS wc;
MSG msg;
HWND hwnd=NULL;
char name[10]="wndcls";
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc=wndproc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.lpszClassName=name;
wc.hInstance=hins;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.lpszMenuName=NULL;
RegisterClass(&wc);
hwnd=CreateWindow(name,"test window",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,
NULL,NULL,NULL,NULL);
if(hwnd==NULL)
{
MessageBox(NULL,"create failed..","error",MB_OK);
return 0;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK wndproc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_QUIT:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,msg,wParam,lParam);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询