你看下能不能顯示.
---------------------5.CPP-----------
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include "5_2.h"
HMENU hmenu,hprintmenu;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hwnd;
MSG Msg;
HACCEL hAccel;
WNDCLASS WndClass;
char lpszClassName[] = "彩单";
char lpszTitle[] = "My_Menu_Example";
WndClass.style = CS_HREDRAW | CS_VREDRAW;
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 = "MENU";
if(!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
}
hwnd = CreateWindow("彩单",
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
hAccel = LoadAccelerators(NULL,"MENU");
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();
AppendMenu(hprintmenu,MF_ENABLED,IDM_LINE,"求和");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RECT,"方差");
AppendMenu(hprintmenu,MF_ENABLED,IDM_RRECT,"平均值");
AppendMenu(hprintmenu,MF_ENABLED,IDM_ELLIP,"均方根");
InsertMenu(hmenu,2,MF_POPUP|MF_BYPOSITION,(UINT)hprintmenu,"统计计算(&C)");
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);
return 0L;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
原來朋友仔感情再天真, 亦是我永遠也會愛惜的人, 明日愛他人, 也記住學會不要緊; 原來朋友比戀人更高分, 亦讓我開始懂得不記恨, 若大家都敏感, 我更要永遠記得拒絕再因小事怪人, 爲何沒有這條校訓...Twins-朋友仔
MCSD Training