Beautiful interface of the software should have a beautiful menu, everyone on the Windows XP Start menu is certainly not unfamiliar with it, the menu unique style. So went to study, and found that it is not true CMenu also not its derived class, the analysis of its structure found that it is mainly composed of two ListView, a toolbar, a Button. So also wrote a menu class, but I did not use ListView to achieve, although not as compared to Windows XP, but I think it is a personalized menu, take out and share! I hope you can write a menu of innovative and independent property rights. Ha ha....... Of course, seeing is the following picture.
First, the realization principle
Use CWnd and CButton to achieve. The main class file is Cyisong Menu.cpp CyisongMenu.h.
Two, the menu uses the method explanation
Class public variable definition:
CYisongMenu m_GroupMenu;
CYisongMenu m_SubGroupMenu;//子菜单
Set avatar and Add menu items:
m_GroupMenu.SetMenuHeader("我的主菜单",IDI_QQ, TRUE );
m_GroupMenu.AppendMenuItem("退出系统",
IDC_SUBITEM, //菜单ID
IDI_ICON1, // 图标
NULL, //子菜单指针
MENU_NORMAL|MENU_FONTBOLD//风格参数
);
m_GroupMenu.AppendMenuItem("功能菜单2",
IDC_SUBITEM+1,
IDI_ICON2,
NULL,
MENU_NORMAL );
Continue adding menu items with Appendmenuitem,
Finish creating
m_GroupMenu.CreateGroupMenu(this,CRect(0,0,150,300),IDC_MENU,1,1);
This completes the creation process, and if you want to create a child menu, go back to a.