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

📄 subject_50364.htm

📁 vc
💻 HTM
字号:
<p>
序号:50364 发表者:圣诞小人 发表日期:2003-08-20 13:29:58
<br>主题:多个菜单(其id连续)一个响应函数如何实现?
<br>内容:譬如级联菜单&nbsp;&nbsp;排序-&gt;按类型(id=1001)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;按时间<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;按大小<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .(id=1010)<BR>如何用一个函数来响应?<BR>其消息影射如何写,<BR>响应函数如何写?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:BenDan 回复日期:2003-08-20 14:01:49
<br>内容:ON_COMMAND_RANGE<BR>Use this macro to map a contiguous range of command IDs to a single message handler function.<BR><BR>ON_COMMAND_RANGE(id1, id2, memberFxn )<BR>Parameters<BR>id1 <BR>Command ID at the beginning of a contiguous range of command IDs. <BR>id2 <BR>Command ID at the end of a contiguous range of command IDs. <BR>memberFxn <BR>The name of the message-handler function to which the commands are mapped. <BR>Remarks<BR>The range of IDs starts with id1 and ends with id2. <BR><BR>Use ON_COMMAND_RANGE to map a range of command IDs to one member function. Use ON_COMMAND to map a single command to a member function. Only one message-map entry can match a given command ID. That is, you can't map a command to more than one handler. For more information on mapping message ranges, see Handlers for Message-Map Ranges.<BR><BR>There is no automatic support for message map ranges, so you must place the macro yourself.<BR><BR>Example<BR>// The code fragment below shows how to use ON_COMMAND_RANGE macro<BR>// to map a contiguous range of command IDs to a single message <BR>// handler function (i.e. OnFileMenuItems() is the sample below). In <BR>// addition, it also shows how to use CheckMenuRadioItem() to check a <BR>// selected menu item and makes it a radio item.<BR>BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)<BR>&nbsp;&nbsp; // ... <BR>&nbsp;&nbsp; ON_COMMAND_RANGE(ID_FILE_MENUITEM1, ID_FILE_MENUITEM3, OnFileMenuItems)<BR>END_MESSAGE_MAP()<BR><BR>void CMainFrame::OnFileMenuItems(UINT nID)<BR>{<BR>&nbsp;&nbsp; CMenu* mmenu = GetMenu();<BR>&nbsp;&nbsp; CMenu* submenu = mmenu-&gt;GetSubMenu(0);<BR>&nbsp;&nbsp; submenu-&gt;CheckMenuRadioItem(ID_FILE_MENUITEM1, ID_FILE_MENUITEM3, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nID, MF_BYCOMMAND);<BR>}<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:圣诞小人 回复日期:2003-08-20 15:33:08
<br>内容:我照您的方法做了,编译没问题,<BR>但是运行时是灰的,<BR>问题在哪里?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:圣诞小人 回复日期:2003-08-30 08:51:09
<br>内容:原来是焦点的缘故
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

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