#include#include "allmenu.h"#include using namespace std;HMENU hmenu;HMENU haddmenu;//窗口函数LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){ switch(message){/* case WM_INIT: hmenu=GetMenu(hwnd);//该函数取得分配给指定窗口的菜单的句柄。 haddmenu=CreateMenu(); AppendMenu(haddmenu,MF_ENABLED,IDM_OPENBIG,"打开目标图像"); AppendMenu(haddmenu,HF_ENABLED,IDM_OPENSMALL,"打开模板图像"); AppendMenu(haddmenu,HF_ENABLED,IDM_EXIT,"退出");/* case WM_COMMAND: switch(LOWORD(wParam)) { hmenu=GetMenu(hwnd); haddmenu=CreateMenu(); AppendMenu(haddmenu,MF_ENABLED,IDM_OPENBIG,"打开目标图像"); AppendMenu(haddmenu,HF_ENABLED,IDM_OPENSMALL,"打开模板图像"); AppendMenu(haddmenu,HF_ENABLED,IDM_EXIT,"退出"); }*/ case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,message,wParam,lParam); } return 0;}//winmain函数int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow){ MSG Msg; WNDCLASS wndclass; HWND hwnd; char lpszClassName[]="我的窗口"; char lpszTitle[]="MyWindows"; char lpszMenuName[]="menu"; hmenu=LoadMenu(hInstance,"hmenu"); wndclass.style=0; wndclass.lpfnWndProc=WndProc; 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=lpszMenuName; 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, hmenu, hInstance, NULL ); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); while(GetMessage(&Msg,NULL,0,0)){ TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam;}//allmenu.h文件#define MYMENU 10#define IDM_OPENSMALL 11#define IDM_OPENBIG 12#define IDM_CLOSE 13#define IDM_EXIT 14