<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : TrackPopupMenu</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Command Bars : TrackPopupMenu]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Mon, 27 Apr 2026 04:27:25 +0000</pubDate>
  <lastBuildDate>Mon, 10 Jan 2011 10:44:28 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=17711</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[TrackPopupMenu :    Hello OlegSorry, I was in...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=62158&amp;title=trackpopupmenu#62158</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3301">Michl</a><br /><strong>Subject:</strong> 17711<br /><strong>Posted:</strong> 10 January 2011 at 10:44am<br /><br />Hello Oleg<br><br>Sorry, I was in christmas holidays.<br><br>I know that only the main thread should create user interfaces. But our problem don't occur in a (normal) executable application. We developed an ad-snapin extension (.dll)<br><br>After you have registered the snapin, windows will be called a COM callback 'AddPages' of interface 'IShellPropSheetExt'. Before, windows must loading the dll and initialize (indirect) MFC (because CWinApp is static object as known). This initialize also the structure wich returns the pointer by calling AfxGetThread(). But this all happens in thread A.<br><br>This functions creates an user defined tab (CPropertyPage) which contains a button for extended settings and returns it. Additional a callback function is defined by a message map. This function is calling, but from thread B!???<br><br>I don't understand it, too.<br>I like to know what windows is doing in his own internal message map!? (perhaps saving main property page for crashes)<br><br>However, in my oppinion it should be possible to create a standalone popup or window with own message loop. If you are not in gui thread (AfxGetThread() == NULL), you should don't call PreTranslateMessage()!<br><br>As you can see, the internal function TrackPopupMenu of MFC works!<br><br>What is your oppinion?<br>]]>
   </description>
   <pubDate>Mon, 10 Jan 2011 10:44:28 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=62158&amp;title=trackpopupmenu#62158</guid>
  </item> 
  <item>
   <title><![CDATA[TrackPopupMenu : Hi,If you need GUI you should...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=61975&amp;title=trackpopupmenu#61975</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 17711<br /><strong>Posted:</strong> 23 December 2010 at 9:08am<br /><br />Hi,<div><br></div><div>If you need GUI you should run&nbsp;<span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">GUI-thread</span><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">. in this case&nbsp;</span><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">AfxGetThread will return CWinThread you created.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><a href="http://msdn.microsoft.com/en-us/library/b807sta6%28v=vs.80%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/b807sta6(v=vs.80).aspx</a></span></div>]]>
   </description>
   <pubDate>Thu, 23 Dec 2010 09:08:24 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=61975&amp;title=trackpopupmenu#61975</guid>
  </item> 
  <item>
   <title><![CDATA[TrackPopupMenu :  Hifirst of all, I know it is...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=61942&amp;title=trackpopupmenu#61942</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3301">Michl</a><br /><strong>Subject:</strong> 17711<br /><strong>Posted:</strong> 22 December 2010 at 3:29am<br /><br />Hi<br><br>first of all, I know it is not a very good programming style - but it is windows :)<br><br>In a windows(!)-system-callback (this is raising in another worker-thread-context!), I like to view a small popup context window with TrackPopupMenu.<br><br>MFC build in function works without assertions. But if I use Codejocks CommandBars the application crashes! I know ToolkitPro is not thread safe, but I don't manipulate data. The question is, ToolkitPro?<br><br><table width="99%"><tr><td><pre class="BBcode"><br>BOOL CXTPCommandBars::TrackPopupMenu(CXTPPopupBar* pPopup, UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT rcExclude, CWnd* pWndOwner)<br>{<br>&nbsp;&nbsp;&nbsp; ASSERT(pPopup);<br>&nbsp;&nbsp;&nbsp; if (!pPopup)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; const MSG&amp; msg = AfxGetThreadState()-&gt;m_lastSentMsg;<br>&nbsp;&nbsp;&nbsp; if (msg.message == WM_CONTEXTMENU &amp;&amp; msg.lParam == MAKELPARAM(-1, -1) &amp;&amp; pPopup-&gt;GetCommandBars())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pPopup-&gt;GetCommandBars()-&gt;ShowKeyboardCues(TRUE);<br><br>&nbsp;&nbsp;&nbsp; if (!pWnd)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pWnd = pPopup-&gt;GetSite();<br><br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_pSite = pWnd ;<br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_pOwner = pWndOwner;<br><br>&nbsp;&nbsp;&nbsp; if (pWnd &amp;&amp; pWnd-&gt;GetExStyle() &amp; (WS_EX_LAYOUTRTL | WS_EX_RIGHT))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nFlags |= TPM_RIGHTALIGN;<br><br>&nbsp;&nbsp;&nbsp; UINT nReturn = TRUE;<br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_pReturnCmd = NULL;<br><br>&nbsp;&nbsp;&nbsp; if (nFlags &amp; TPM_RETURNCMD)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pPopup-&gt;m_pReturnCmd = &amp;nReturn;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; nReturn = 0;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_bExecOnRButton = nFlags &amp; TPM_RIGHTBUTTON;<br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_bIgnoreUpdateHandler = nFlags &amp; TPM_NONOTIFY;<br><br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_popupFlags = 0;<br>&nbsp;&nbsp;&nbsp; if (nFlags &amp; TPM_RIGHTALIGN)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pPopup-&gt;m_popupFlags |= xtpPopupLeft;<br><br>&nbsp;&nbsp;&nbsp; if (nFlags &amp; TPM_BOTTOMALIGN)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pPopup-&gt;m_popupFlags |= xtpPopupUp;<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pPopup-&gt;m_popupFlags |= xtpPopupDown;<br><br>&nbsp;&nbsp;&nbsp; BOOL bRecurse = nFlags &amp; TPM_RECURSE;<br>&nbsp;&nbsp;&nbsp; pPopup-&gt;m_bRecursePopup = bRecurse;<br><br>&nbsp;&nbsp;&nbsp; CXTPMouseManager* pMouseManager = XTPMouseManager();<br><br>&nbsp;&nbsp;&nbsp; if (!bRecurse)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pMouseManager-&gt;SendTrackLost();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ReleaseCapture();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pMouseManager-&gt;SendTrackLostRecurse();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pMouseManager-&gt;LockTrackRecurse(TRUE);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; pMouseManager-&gt;IgnoreLButtonUp();<br><br>&nbsp;&nbsp;&nbsp; if (!pPopup-&gt;Popup(x, y, rcExclude))<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return FALSE;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; <font color="#ff0000">pPopup-&gt;PumpMessage();</font><br><br>&nbsp;&nbsp;&nbsp; if (bRecurse)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pMouseManager-&gt;LockTrackRecurse(FALSE);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; return nReturn;<br>}<br><br><br>void CXTPPopupBar::PumpMessage()<br>{<br>&nbsp;&nbsp;&nbsp; CXTPMouseManager* pMouseManager = XTPMouseManager();<br><br>&nbsp;&nbsp;&nbsp; while (IsTrackingMode())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; MSG msg;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (::PeekMessage(&amp;msg, NULL, 0, 0, PM_NOREMOVE))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (pMouseManager-&gt;PreviewTackLost(this, &amp;msg))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetTrackingMode(FALSE);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!::GetMessage(&amp;msg, NULL, 0, 0))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (!IsTrackingMode())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ::PostMessage(msg.hwnd, msg.message, msg.wParam, msg.lParam);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (msg.message != WM_KICKIDLE &amp;&amp; !<font color="#ff0000">AfxGetThread()-&gt;PreTranslateMessage(&amp;msg)</font>)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // process this message<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ::TranslateMessage(&amp;msg);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ::DispatchMessage(&amp;msg);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WaitMessage();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>}<br></pre></td></tr></table><br><br><font color="#000000">AfxGetThread()</font> returns NULL because theApp object was created in main thread. This is correct and highly recommended to avoid simultaneous execution.<br><br>What do you mean, Oleg? Make it sense to check pointer and call only<font color="#000000"> </font><font color="#000000">PreTranslateMessage in same thread? Or avoid using your TrackPopupMenu because more functions potentially unsafe.<br><br>Thanks<br></font>]]>
   </description>
   <pubDate>Wed, 22 Dec 2010 03:29:25 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=17711&amp;PID=61942&amp;title=trackpopupmenu#61942</guid>
  </item> 
 </channel>
</rss>