<?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 : Context menu tracking when Skinning</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Skin Framework : Context menu tracking when Skinning]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Tue, 01 Sep 2026 16:11:46 +0000</pubDate>
  <lastBuildDate>Tue, 01 Sep 2026 13:33:35 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>30</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=24694</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[Context menu tracking when Skinning : Mea cupla. It wasn&amp;#039;t skinning...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=24694&amp;PID=79473&amp;title=context-menu-tracking-when-skinning#79473</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3213">rdhd</a><br /><strong>Subject:</strong> 24694<br /><strong>Posted:</strong> 01 September 2026 at 1:33pm<br /><br /><div>Mea cupla. It wasn't skinning that caused the dismissal. It was the fact that I had to use CJ TrackPopupMenu to get the skin applied to the context menu. We have the code here being used in cases where we don't have a popup displaying the item for which we are showing the context menu.</div><div><br></div><div>So I guess the work-around I have though seemingly a bit dangerous (subject to CJ changes over time ...) is probably the best I can do.</div>]]>
   </description>
   <pubDate>Tue, 01 Sep 2026 13:33:35 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=24694&amp;PID=79473&amp;title=context-menu-tracking-when-skinning#79473</guid>
  </item> 
  <item>
   <title><![CDATA[Context menu tracking when Skinning : I found that when I have a skin...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=24694&amp;PID=79472&amp;title=context-menu-tracking-when-skinning#79472</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3213">rdhd</a><br /><strong>Subject:</strong> 24694<br /><strong>Posted:</strong> 01 September 2026 at 1:18pm<br /><br /><div>I found that when I have a skin applied and I do a right click on a control on some of our popups the context menu I track causes the popup to dismiss. To fix that I found I could pass in TPM_RECURSE when tracking the popup menu. That keeps CJ from closing the popup. Unfortunately it also lets CJ track the mouse wrt the popup as well as the context menu (popup itself). Well sort of. The context menu items don't highlight as I move over them though the items on the popup below it do. When I click a context menu item I do get the command ID back.</div><div><br></div><div>Not a fan of my work-around which is described and implemented as:</div><div><br></div><div><pre style="font-family:'Cascadia Mono';font-size:9pt;color:#000000">            <span style="color:#008000">// 12/22/25: RDH PR 11388058. This code was changed to call the frame window so the menu displays a Dark</span>            <span style="color:#008000">// theme. That api routes through Codejock's CXTPCommandBars::TrackPopupMenu, which calls</span>            <span style="color:#008000">// XTPMouseManager::SendTrackLost on entry. SendTrackLost walks CXTPMouseManager::m_arrTracked calling</span>            <span style="color:#008000">// OnTrackLost, which ends tracking mode on the MRUPopupBar and closes the vertical MRU out from under us.</span>            <span style="color:#008000">//</span>            <span style="color:#008000">// 8/31/26 RDH: That was originally worked around by passing TPM_RECURSE, because Codejock skips</span>            <span style="color:#008000">// SendTrackLost when that flag is set. But TPM_RECURSE does not mean "leave my popup alone" - it also</span>            <span style="color:#008000">// calls LockTrackRecurse(TRUE), which bumps m_nLockRecurse on EVERY bar already being tracked, and</span>            <span style="color:#008000">// m_nLockRecurse is the flag that gates all hot tracking (CXTPPopupBar::OnMouseMove,</span>            <span style="color:#008000">// CXTPCommandBar::OnMouseMove and OnMouseLeave, the hover timers, CXTPMouseManager::DeliverMessage).</span>            <span style="color:#008000">// The result was a context menu whose items never highlighted, and stale highlights left lit on the MRU</span>            <span style="color:#008000">// items underneath because nothing was allowed to clear them.</span>            <span style="color:#008000">//</span>            <span style="color:#008000">// Removing just our own bar from the tracked array is not enough, and it is worth knowing why. An</span>            <span style="color:#008000">// MRUPopupBar is a CXTPRibbonSystemPopupBarPage, that is, a page of the system menu popup that spawned</span>            <span style="color:#008000">// it, and that parent bar is tracked too. SendTrackLost calls OnTrackLost on the parent, the parent</span>            <span style="color:#008000">// closes its child popups, and ours goes down with it however carefully we detached it. That is exactly</span>            <span style="color:#008000">// what TPM_RECURSE was papering over by locking the whole array rather than one entry.</span>            <span style="color:#008000">//</span>            <span style="color:#008000">// So do what TPM_RECURSE did, minus the freeze: lift the entire tracked array out for the duration of</span>            <span style="color:#008000">// the call and put it back afterwards. SendTrackLost then has nothing to walk and is a no op, every</span>            <span style="color:#008000">// bar keeps its tracking mode, and because nobody gets m_nLockRecurse set the context menu hot tracks</span>            <span style="color:#008000">// normally. The bars are restored in their original order, since SetTrack appends.</span>            <span style="color:#008000">//</span>            <span style="color:#008000">//</span>            <span style="color:#008000">// Do not try to solve this by vetoing dismissal in MRUPopupBar::SetTrackingMode instead. SendTrackLost</span>            <span style="color:#008000">// is "while (m_arrTracked.GetSize() &gt; 0) m_arrTracked&#091;0&#093;-&gt;OnTrackLost();" - a veto that stops a bar</span>            <span style="color:#008000">// being removed from the array hangs the thread.</span>            <span style="color:#2b91af">CXTPCommandBar</span>*   pOwningBar     = <span style="color:#6f008a">DYNAMIC_DOWNCAST</span><span style="color:#1a94ff">(</span><span style="color:#2b91af">MRUPopupBar</span>, GetParent<span style="color:#ffd702">()</span><span style="color:#1a94ff">)</span>;            <span style="color:#2b91af">CXTPMouseManager</span>* pMouseManager  = XTPMouseManager<span style="color:#1a94ff">()</span>;            std::<span style="color:#2b91af">vector</span>&lt;<span style="color:#2b91af">CXTPCommandBar</span>*&gt; vecSuspendedBars;            <span style="color:#0000ff">if</span><span style="color:#1a94ff">(</span>pOwningBar &amp;&amp; pMouseManager<span style="color:#1a94ff">)</span>            <span style="color:#1a94ff">{</span>                <span style="color:#2b91af">CXTPMouseManager</span>::<span style="color:#2b91af">CTrackArray</span>&amp; arrTracked = pMouseManager-&gt;GetTrackArray<span style="color:#ffd702">()</span>;                <span style="color:#0000ff">for</span><span style="color:#ffd702">(</span><span style="color:#0000ff">int</span> i = 0; i &lt; <span style="color:#d86ac2">(</span><span style="color:#0000ff">int</span><span style="color:#d86ac2">)</span>arrTracked.GetSize<span style="color:#d86ac2">()</span>; i++<span style="color:#ffd702">)</span>                <span style="color:#ffd702">{</span>                    vecSuspendedBars.push_back<span style="color:#d86ac2">(</span>arrTracked<span style="color:#008080">&#091;</span>i<span style="color:#008080">&#093;</span><span style="color:#d86ac2">)</span>;                <span style="color:#ffd702">}</span>                <span style="color:#0000ff">for</span><span style="color:#ffd702">(</span><span style="color:#2b91af">size_t</span> i = 0; i &lt; vecSuspendedBars.size<span style="color:#d86ac2">()</span>; i++<span style="color:#ffd702">)</span>                <span style="color:#ffd702">{</span>                    pMouseManager-&gt;RemoveTrack<span style="color:#d86ac2">(</span>vecSuspendedBars<span style="color:#008080">&#091;</span>i<span style="color:#008080">&#093;</span><span style="color:#d86ac2">)</span>;                <span style="color:#ffd702">}</span>            <span style="color:#1a94ff">}</span>            <span style="color:#2b91af">BOOL</span> item = pFrameWnd-&gt;TrackPopupMenu<span style="color:#1a94ff">(</span>subMenu, <span style="color:#6f008a">TPM_RETURNCMD</span> | <span style="color:#6f008a">TPM_LEFTALIGN</span> | <span style="color:#6f008a">TPM_LEFTBUTTON</span>, point.x, point.y, <span style="color:#0000ff">this</span>, <span style="color:#0000ff">nullptr</span>, <span style="color:#2f4f4f">JNone</span>, hInstance<span style="color:#1a94ff">)</span>;            <span style="color:#0000ff">for</span><span style="color:#1a94ff">(</span><span style="color:#2b91af">size_t</span> i = 0; i &lt; vecSuspendedBars.size<span style="color:#ffd702">()</span>; i++<span style="color:#1a94ff">)</span>            <span style="color:#1a94ff">{</span>                <span style="color:#008000">// The window can be gone if a command tore the bar down while the menu was up.</span>                <span style="color:#0000ff">if</span><span style="color:#ffd702">(</span>::IsWindow<span style="color:#d86ac2">(</span>vecSuspendedBars<span style="color:#008080">&#091;</span>i<span style="color:#008080">&#093;</span>-&gt;GetSafeHwnd<span style="color:#1a94ff">()</span><span style="color:#d86ac2">)</span><span style="color:#ffd702">)</span>                <span style="color:#ffd702">{</span>                    pMouseManager-&gt;SetTrack<span style="color:#d86ac2">(</span>vecSuspendedBars<span style="color:#008080">&#091;</span>i<span style="color:#008080">&#093;</span>, <span style="color:#6f008a">FALSE</span><span style="color:#d86ac2">)</span>;                <span style="color:#ffd702">}</span>            <span style="color:#1a94ff">}</span></pre><br></div><div>As I noted before the code related to suspending and resuming tracking I made to keep the popup displayed when a skin was applied was to add TPM_RECUSE to the flags passed in. I did not determine why a skin being applied caused the dismissal and no skin applied kept the popup from being dismissed when tracking the context menu on an item in that popup. The above code now keeps the popup from being dismissed while allowing correct tracking on the item I am showing the context menu for.</div>]]>
   </description>
   <pubDate>Tue, 01 Sep 2026 13:18:38 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=24694&amp;PID=79472&amp;title=context-menu-tracking-when-skinning#79472</guid>
  </item> 
 </channel>
</rss>