#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 & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX; //设置窗体样式 /*窗口类设置*/ wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wndClass.lpfnWndProc=WindowProc; 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=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; }