#include <windows.h> /*消息处理函数声明*/ HRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hwnd; MSG message; WNDCLASS wndClass; char szClassName[] = "MainWindonClass";//窗体类名 DWORD dwStyle = WS_OVERLAPPEDWINDOW; //设置窗体样式 ,禁止改变窗体大小 /*窗口类设置*/ wndClass.style = CS_DBLCLKS; wndClass.lpfnWndProc=WindowProc; wndClass.cbClsExtra=0; wndClass.cbWndExtra=0; wndClass.hInstance=hInstance; wndClass.hIcon=(HICON)LoadImage(NULL,"1.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE); wndClass.hCursor=LoadCursor (NULL, IDC_ARROW); wndClass.hbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH); wndClass.lpszMenuName=NULL; wndClass.lpszClassName=szClassName; /*窗口类注册*/ if( RegisterClass(&wndClass) == 0 ) return 0;//表示注册失败 /*创建窗体*/ hwnd = CreateWindow(szClassName, "禁止改变窗体大小", dwStyle,//设置窗体样式 300, 300, 300, 300, NULL, NULL, hInstance, NULL ); if(hwnd == 0) { MessageBox(NULL,"窗体创建失败!","失败",MB_OK); return 0; } /* 显示窗体 */ ShowWindow(hwnd,nCmdShow); while (GetMessage (&message, NULL, 0, 0)) { TranslateMessage(&message);//翻译 DispatchMessage(&message);//发送消息 } return message.wParam; } /*消息处理*/ LRESULT CALLBACK WindowProc(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; }