#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>#define IDM_NEW 10
#define IDM_OPEN 11
#define IDM_CLOSE 12
#define IDM_SAVE 13
#define IDM_SAVEAS 14
#define IDM_ADDPRINTMENU 15
#define IDM_DELPRINTMENU 16
#define IDM_EXIT 17
#define IDM_CUT 18
#define IDM_COPY 19
#define IDM_PASTE 20
#define IDM_DELETE 21
#define IDM_HELP 22
#define IDM_LINE 23
#define IDM_RECT 24
#define IDM_RRECT 25
#define IDM_ELLIP 26HMENU hMenu,hPrintMenu;LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,
   LPSTR lpCmdLine,int nCmdShow)
{
HWND hWnd;
MSG Msg;
WNDCLASS WndClass;
HACCEL hAccel;
char lpszMenuName[] = "Menu";
char lpszClassName[] = "菜单";
char lpszTitle[] = "Example of Menu";

WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = lpszClassName;
WndClass.lpszMenuName = lpszMenuName;
WndClass.style = 0; 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); hAccel = LoadAccelerators(hInstance,lpszMenuName); while(GetMessage(&Msg,NULL,0,0))
{
if(!TranslateAccelerator(hWnd,hAccel,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}LRESULT CALLBACK WndProc(HWND hWnd,UINT Message,
 WPARAM wParam,LPARAM lParam)
{
switch(Message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_NEW: 
break;
case IDM_OPEN:
break;
case IDM_SAVE:
break;
case IDM_SAVEAS:
break;
case IDM_CLOSE:
break;
case IDM_ADDPRINTMENU:
hMenu = GetMenu(hWnd);
hPrintMenu = CreateMenu();
InsertMenu(hMenu,2,MF_POPUP|MF_BYPOSITION,
(UINT)hPrintMenu,"统计计算(&C)");
AppendMenu(hPrintMenu,MF_ENABLED,IDM_LINE,"求和");
AppendMenu(hPrintMenu,MF_ENABLED,IDM_RECT,"方差");
AppendMenu(hPrintMenu,MF_ENABLED,IDM_RRECT,"平均值");
AppendMenu(hPrintMenu,MF_ENABLED,IDM_ELLIP,"均方根");
EnableMenuItem(hMenu,IDM_ADDPRINTMENU,MF_GRAYED);
EnableMenuItem(hMenu,IDM_DELPRINTMENU,MF_ENABLED);
DrawMenuBar(hWnd);
break;
case IDM_DELPRINTMENU:
DeleteMenu(hMenu,2,MF_BYPOSITION);
EnableMenuItem(hMenu,IDM_ADDPRINTMENU,MF_ENABLED);
EnableMenuItem(hMenu,IDM_DELPRINTMENU,MF_GRAYED);
DrawMenuBar(hWnd);
break;
case IDM_EXIT:
SendMessage(hWnd,WM_DESTROY,0,0);
break;
case IDM_CUT:
break;
case IDM_COPY:
break;
case IDM_PASTE:
break;
case IDM_DELETE:
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,Message,wParam,lParam);
}
return 0;
}