📄 subject_53983.htm
字号:
<p>
序号:53983 发表者:莹莹菜 发表日期:2003-09-24 17:31:55
<br>主题:弹出式菜单的问题
<br>内容:学习VC第8天,做了一个项目名为Menus的对话框风格的小程序,全是按照教材写的代码,以下是点击左键实现弹出式菜单的函数,编译提示出现一个错误,拜托帮我诊断一下吧。<BR><BR>错误提示<BR>error C2660: 'GetSubMenu' : function does not take 0 parameters<BR>warning C4552: '>>' : operator has no effect; expected operator with side-effect<BR><BR><BR>void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point) <BR>{<BR> // TODO: Add your message handler code here<BR><BR> ////////////////////////////////<BR> // MY CODE STARTS HERE<BR> ////////////////////////////////<BR><BR> // Delare local variables<BR> CMenu *m_lMenu; // A ponter to the menu<BR> CPoint m_pPoint; // A Copy of the mouse position<BR><BR> // Copy the mouse position to a local variable<BR> m_pPoint = point;<BR> // Convert the position to a screen position<BR> ClientToScreen(&m_pPoint);<BR> // Get a pointer to the window menu<BR> m_lMenu - GetMenu(); 敬告提示行<BR> // Get a pointer to the first submenu<BR> m_lMenu = m_lMenu->GetSubMenu(); 错误提示行<BR> // Show the popup menu<BR> m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, m_pPoint.x, m_pPoint.y, this, NULL);<BR><BR> ////////////////////////////<BR> // MY CODE ENDS HERE<BR> ////////////////////////////<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>
回复者:david_zhao 回复日期:2003-09-24 18:49:05
<br>内容:GetSubMenu(); 应该带参数
<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-09-24 20:16:36
<br>内容:加上参数后,编译通过了,功能没有实现,并且出现BUG。教材上就没有什么参数,应该怎么改一下呀?<BR><BR>两个警告错误:<BR>warning C4552: '>>' : operator has no effect; expected operator with side-effect<BR>warning C4700: local variable 'm_lMenu' used without having been initialized<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-09-25 09:14:49
<br>内容:CMenu menu;<BR>menu.LoadMenu (your menu resource ID);<BR>CMenu *m_lMenu =menu.GetSubMenu (0);<BR>m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, point.x, point.y, this, NULL);<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-09-25 10:23:22
<br>内容:void CMenusDlg::OnContextMenu(CWnd* pWnd, CPoint point) <BR>{<BR> // TODO: Add your message handler code here<BR><BR> ////////////////////////////////<BR> // MY CODE STARTS HERE<BR> ////////////////////////////////<BR><BR> // Delare local variables<BR> CMenu *m_lMenu; // A pointer to the menu<BR> CPoint m_pPoint; // A Copy of the mouse position<BR><BR> // Copy the mouse position to a local variable<BR> m_pPoint = point;<BR> // Convert the position to a screen position<BR> ClientToScreen(&m_pPoint);<BR> // Get a pointer to the window menu<BR> //m_lMenu - GetMenu();<BR> // Get a pointer to the first submenu<BR> <BR> ///////////////////////////////////////<BR> // david_zhao'contribution<BR> // ***thanks!***<BR> //m_lMenu = m_lMenu->GetSubMenu(0); <BR> ////////////////////////////////////// <BR> <BR> // Show the popup menu<BR> <BR> //////////////////////////////////////////<BR> // 小灿'contribution *****GOAL!!!*****<BR> CMenu menu;<BR> menu.LoadMenu (IDR_MENU1);<BR> m_lMenu =menu.GetSubMenu (0);<BR> //////////////////////////////////////////<BR><BR><BR> m_lMenu->TrackPopupMenu(TPM_CENTERALIGN + TPM_LEFTBUTTON, m_pPoint.x,<BR> m_pPoint.y, this, NULL);<BR><BR> ////////////////////////////<BR> // MY CODE ENDS HERE<BR> ////////////////////////////<BR> <BR>}<BR><BR><big>Thank</big> david_zhao and 小灿!!!<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 + -