如何向系统菜单中动态添加菜单项

1、什么是系统菜单?

       所谓系统菜单就是指你在应用程序标题栏上鼠标右键操作时弹出的菜单,如下图所示:

2、如何在系统菜单中动态添加菜单项

       // 修改系统菜单

       CMenu* system_menu;

       system_menu = pFrm->GetSystemMenu(false);

       system_menu->AppendMenu(MF_SEPARATOR);  

       system_menu->AppendMenu(MF_STRING,ID_NORMALVIEW,"正常查看(&N)/tF12");

       system_menu->AppendMenu(MF_STRING,ID_FULLSCREEN,"全屏幕查看(&F)/tF12");

       system_menu->AppendMenu(MF_STRING,ID_STRETCHVIEW,"拉伸模式(&S)/tF12");

       system_menu->CheckMenuItem(ID_STRETCHVIEW,MF_BYCOMMAND|MF_CHECKED);

       system_menu->AppendMenu(MF_SEPARATOR);  

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"发送Ctrl-Alt-&Del/tC-A-F12");

       system_menu->AppendMenu(MF_BYPOSITION|MF_POPUP,(UINT)CreatePopupMenu(),"发送特殊键(&K)");

       CMenu *pAddinMenu = system_menu->GetSubMenu(system_menu->GetMenuItemCount()-1);      

                     pAddinMenu->AppendMenu(MF_BYPOSITION|MF_STRING|MF_ENABLED,ID_MYMENUITEM,"Ctrl-Esc");

                     pAddinMenu->AppendMenu(MF_BYPOSITION|MF_STRING|MF_ENABLED,ID_MYMENUITEM,"F12");

                     pAddinMenu->AppendMenu(MF_BYPOSITION|MF_STRING|MF_ENABLED,ID_MYMENUITEM,"Ctrl-F12");

                     pAddinMenu->AppendMenu(MF_BYPOSITION|MF_STRING|MF_ENABLED,ID_MYMENUITEM,"Alt-F12");

                     pAddinMenu->AppendMenu(MF_BYPOSITION|MF_STRING|MF_ENABLED,ID_MYMENUITEM,"Ctrl-Alt-F12");

       system_menu->AppendMenu(MF_SEPARATOR);  

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"获取剪贴板内容(&G)");

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"设置剪贴板内容(&T)");

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"关机(&W)...");

       system_menu->AppendMenu(MF_SEPARATOR);

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"选项(&O)...");

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"连接信息(&I)...");

       system_menu->AppendMenu(MF_STRING,ID_MYMENUITEM,"关于(&A)...");

       修改后的菜单如下图所示:

3、给菜单项添加消息处理

       和普通菜单一样,加入消息处理即可,这里不再赘述。

 

如果你是VC程序员或爱好者,而且想和大家一起交流你的经验,都可以加入群“VC程序员之家群一(号码:74515881)”或“VC程序员之家群二(号码:30844241)”。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值