创建windows窗口 求改码 真心不会改了
#include<windows.h>#include<stdio.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstances,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nComdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
char lpszClassName[]="窗口";
char lpszTitle[]="My_Windows";
//窗口类定义
wndclass.style=0;
wndclass.lpfnWndProc=WndProc ;
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=lpszClassName ;
//-------以下进行窗口类的注册----
if(!RegisterClass(&wndclass))
{
MessageBeep(0);
return FALSE;
}
//创建窗口
hwnd=CreateWindow(
lpszClassName,
lpszTitle,
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);
}
//窗口函数
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
}