⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index059.htm

📁 一本不错的VC编程的参考书
💻 HTM
字号:
<html>
<style type="text/css"><!--
.p9 {  font-family: "宋体"; font-size: 9pt}a        {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">如何给系统菜单添加一个菜单项</font></td></tr>
<tr><td><p>
</Br>
给系统菜单添加一个菜单项需要进行下述三个步骤:<Br>
首先,使用Resource Symbols对话(在View菜单中选择Resource Symbols...可以显示该对话)定义菜单项ID,该ID应大于0x0F而小于0xF000;<Br>
其次,调用CWnd::GetSystemMenu获取系统菜单的指针并调用CWnd:: Appendmenu将菜单项添加到菜单中。下例给系统菜单添加两个新的<Br>
int CMainFrame:: OnCreate (LPCREATESTRUCT lpCreateStruct)<Br>
{<Br>
&nbsp;…<Br>
&nbsp;//Make sure system menu item is in the right range.<Br>
&nbsp;ASSERT (IDM_MYSYSITEM &0xFFF0)==IDM_MYSYSITEM)<Br>
&nbsp;ASSERT (IDM-MYSYSITEM<0xF000)<Br>
</Br>
&nbsp;//Get pointer to system menu.<Br>
&nbsp;CMenu* pSysmenu=GetSystemmenu (FALSE)<Br>
&nbsp;ASSERT_VALID (pSysMenu)<Br>
&nbsp;//Add a separator and our menu item to system menu.<Br>
&nbsp;CString StrMenuItem (_T ("New menu item"))<Br>
&nbsp;pSysMenu->Appendmenu (MF_SEPARATOR)<Br>
&nbsp;pSysMenu->AppendMenu (MF_STRING, IDM_MYSYSITEM, strMenuitem)<Br>
</Br>
&nbsp;…<Br>
}<Br>
</Br>
现在,选择系统菜单项时用户应进行检测。使用ClassWizard处理WM_SYSCOMMAND消息并检测用户菜单的nID参数:<Br>
void CMainFrame:: OnSysCommand (UINT nID,LPARAM lParam)<Br>
{<Br>
&nbsp;//Determine if our system menu item was selected.<Br>
&nbsp;if ( (nID & 0xFFF0)==IDM_MYSYSITEM)<Br>
&nbsp;{<Br>
&nbsp;//TODO-process system menu item<Br>
&nbsp;}<Br>
</Br>
&nbsp;else<Br>
&nbsp;CMDIFrameWnd ::OnSysCommand (nID, lParam)<Br>
}<Br>
最后,一个设计良好的UI应用程序应当在系统菜单项加亮时在状态条显示一个帮助信息,这可以通过增加一个包含系统菜单基ID的串表的入口来实现。<Br>
</Br>
</p></td></tr>
</table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -