📄 track_popup.shtml.htm
字号:
<HTML>
<!-- Header information-->
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Author" CONTENT="Guy Gascoigne - Piggford">
<TITLE>Menu - Using CMenu::TrackPopupMenu as an Immediate Function</TITLE>
</HEAD>
<!-- Set background properties -->
<body background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed">
<!-- A word from our sponsors... -->
<table WIDTH="100%">
<tr WIDTH="100%"><td><td></tr>
</table>
<!-- Article Title -->
<CENTER><H3><FONT COLOR="#AOAO99">
Using CMenu::TrackPopupMenu as an Immediate Function
</FONT></H3></CENTER>
<CENTER><H3><HR></H3></CENTER>
<!-- Author and contact details -->
This article was contributed by <A HREF="mailto:rmore@cri.com">Randy More</A>.
<!-- The article... -->
<P>It is possible to make the TrackPopupMenu method of CMenu return the value of
the item that was selected rather than having to process the menu commands
through the message map. This is possible using two undocumented flags
TPM_NONOTIFY and TPM_RETURNCMD. As their names imply the first causes the menu
not to send a command massage, and the second causes the method to return the ID
of the command selected. If no command was selected the value returned is 0.</P>
<pre><tt><font COLOR="#990000">
CMenu menu;
int pMenuID = 0;
DWORD SelectionMade;
VERIFY(menu.LoadMenu(IDR_MENU1));
CMenu* pPopup = menu.GetSubMenu(pMenuID);
ASSERT(pPopup != NULL);
POINT pp;
GetCursorPos(&pp);
SelectionMade = pPopup->TrackPopupMenu(
TPM_LEFTALIGN | TPM_LEFTBUTTON |
TPM_NONOTIFY | TPM_RETURNCMD, <strong>//**NOTE** Undocumented flags</strong>
pp.x,pp.y,this);
pPopup->DestroyMenu();
//The value of SelectionMade is
//the id of the command selected
//or 0 if no selection was made
switch(SelectionMade)
{
// ..... do something here .....
}
</font></tt></pre>
<!-- Remember to update this -->
<p>Last updated: 18 April 1998
<P><HR>
<!-- Codeguru contact details -->
<TABLE BORDER=0 WIDTH="100%">
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="../index.htm" tppabs="http://www.codeguru.com/">Goto HomePage</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© 1997 Zafir Anjum</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
<!-- Counter -->
<CENTER><FONT SIZE=-2>955</FONT></CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -