程序中要#include"resouce.h"static TCHAR szMenuName[] = TEXT ("MainMenu") ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szMenuName[] = TEXT ("MainMenu") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
// save the application's HINSTANCE
hInst = hInstance ; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ; // WndProc !!! here
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, "myiocn") ; // how to load self-cus icon
wndclass.hCursor = NULL ;
wndclass.hbrBackground = NULL ;
wndclass.lpszMenuName = szMenuName ;
wndclass.lpszClassName = szAppName ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szMenuName[] = TEXT ("MainMenu") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
// save the application's HINSTANCE
hInst = hInstance ; wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ; // WndProc !!! here
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (hInstance, "myiocn") ; // how to load self-cus icon
wndclass.hCursor = NULL ;
wndclass.hbrBackground = NULL ;
wndclass.lpszMenuName = szMenuName ;
wndclass.lpszClassName = szAppName ;
HMENU LoadMenu(
HINSTANCE hInstance, // handle to module
LPCTSTR lpMenuName // menu name or resource identifier
);
用法:HMENU hmenu=LoadMenu(hInstance,MAKEINTRESOURCE("IDR_MENU1"))
用完后使用DestroyMenu(hmenu)释放资源
我的方法是强制将菜单资源的ID设成与应用的ID一致。
见笑!!