不知道毛病在哪里 为什么显示不了菜单 程序如下
resource.h#define IDM_EXIT 40001
#define IDM_SHOWTOOLBAR 40002
#define IDM_IDM_SHOWSTATUSBAR 40003
appmenu.rc
#include "resource.h"
APPMENU MENU DISCARDABLE
BEGIN
MENUITEM"退出(&X)", IDM_EXIT
POPUP"查看(&V)"
BEGIN
MENUITEM"工具栏(&T)", IDM_SHOWTOOLBAR
MENUITEM"状态栏(&S)", IDM_SHOWSTATUSBAR
END
END
#include <windows.h>
#include <string.h>
#include "resource.h"
char *p="windows程序资源使用练习!";
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(message)
{
case WM_PAINT:hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,200,200,p,lstrlen(p));
EndPaint(hwnd,&ps);return 0;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDM_EXIT:PostQuitMessage(0);return 0;break;
case IDM_SHOWTOOLBAR:
case IDM_IDM_SHOWSTATUSBAR:MessageBox(NULL,"练习","资源练习",MB_OK);return 0;break;
default:return DefWindowProc(hwnd,message,wParam,lParam);
}
case WM_DESTROY:PostQuitMessage(0);return 0;break;
default:return DefWindowProc(hwnd,message,wParam,lParam);
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize=sizeof(WNDCLASS);
wndclass.style=0;
wndclass.lpfnWndProc=WinProc;
wndclass.hInstance=hInstance;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName="APPMENU";
wndclass.lpszClassName="simp";
wndclass.hIconSm=LoadIcon(NULL,IDI_WINLOGO);
if(!RegisterClassEx(&wndclass))
{
if(!RegisterClass((LPWNDCLASS)&wndclass.style))
return 0;
}
hwnd=CreateWindow("simp","菜单资源练习",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,0,0,hInstance,0);
if(!hwnd)
return 0;
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
[[it] 本帖最后由 llp108 于 2008-10-20 21:34 编辑 [/it]]