#include<windows.h>
发布网友
发布时间:50分钟前
我来回答
共1个回答
热心网友
时间:2024-12-05 05:42
#include<windows.h>
LRESULT CALLBACK Wndproc(HWND,UINT,WPARAM,LPARAM);//windpws main' diclare
//以下初始化窗口类
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR IpszCmdLine,int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcex;
char IpszClassName[]="窗口";
char IpszTitle[]="My_Windows";
//窗口类定义
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)Wndproc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName =IpszClassName;
wcex.hIconSm = LoadIcon(wcex.hInstance, IDI_HAND);
//以下进行窗口类的注册
if(!RegisterClassEx(&wcex))
{
MessageBeep(0);
return FALSE;
}
//创建窗口
hwnd=CreateWindow(IpszClassName,IpszTitle,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 msg.wParam;
}
//窗口函数
LRESULT CALLBACK Wndproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM Iparam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,Iparam);
}
return 0;
}