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

📄 subject_31594.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:31594 发表者:chd 发表日期:2003-03-05 16:50:58
<br>主题:关于动态创建菜单的小问题
<br>内容:我想动态建菜单,用的是如下代码:<BR>&nbsp;&nbsp;&nbsp;&nbsp;CWnd *pParent=GetParent();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMenu *pMenu=pParent-&gt;GetMenu();<BR>&nbsp;&nbsp;&nbsp;&nbsp;CMenu *SubMenu=pMenu-&gt;GetSubMenu(5);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;SubMenu-&gt;AppendMenu(MF_STRING|MF_ENABLED,New_Lap_ID++,“1”);<BR><BR>但是所建的菜单不能如图所示的那样,在y菜单的下拉菜单里。1,2,3为要动态添加的菜单。<BR>因为我不能用GetSubMenu获得指向y菜单的指针,因为参数不允许。我该怎么办呢?<BR><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>
回复者:chd 回复日期:2003-03-05 16:53:19
<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>
<font color=red>答案被接受</font><br>回复者:旺崽 回复日期:2003-03-05 17:03:32
<br>内容:CreatePopupMenu()<BR>这是MSDN中的一个例子,对你或许有帮助<BR>// The code fragment below shows how to create a new menu for the<BR>// application window using CreateMenu() and CreatePopupMenu().<BR>// Then, the created menu will replace the current menu of the<BR>// application. The old menu will be destroyed with DestroyMenu().<BR>// NOTE: The code fragment below is done in a CFrameWnd-derived class.<BR><BR>// Create a new menu for the application window.<BR>VERIFY(m_NewMenu.CreateMenu());<BR><BR>// Create a "File" popup menu and insert this popup menu to the<BR>// new menu of the application window. The "File" menu has only<BR>// one menu item, i.e. "Exit".<BR>VERIFY(m_FileMenu.CreatePopupMenu());<BR>m_FileMenu.AppendMenu(MF_STRING, ID_APP_EXIT, (LPCTSTR)"E&amp;xit");<BR>m_NewMenu.AppendMenu(MF_POPUP, (UINT) m_FileMenu.m_hMenu, "&amp;File");<BR><BR>// Remove and destroy old menu<BR>SetMenu(NULL);<BR>CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault);<BR>old_menu-&gt;DestroyMenu();<BR><BR>// Add new menu.<BR>SetMenu(&amp;m_NewMenu);<BR><BR>// Assign default menu<BR>m_hMenuDefault = m_NewMenu.m_hMenu;
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:chd 回复日期:2003-03-06 18:31:15
<br>内容:函数太多了<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 + -