<?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 : OnCreateControl not called for menu items</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Command Bars : OnCreateControl not called for menu items]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 10 Jun 2026 15:46:08 +0000</pubDate>
  <lastBuildDate>Tue, 22 May 2007 08:09:58 +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=7199</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[OnCreateControl not called for menu items : Hi,I&amp;#039;m using Xtreme Toolkit...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23152&amp;title=oncreatecontrol-not-called-for-menu-items#23152</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3014">mschumi</a><br /><strong>Subject:</strong> 7199<br /><strong>Posted:</strong> 22 May 2007 at 8:09am<br /><br />Hi,<br><br>I'm using Xtreme Toolkit Pro 2006 Q4 (10.4).<br>For reproduction, I inserted the following lines of code at the end of CMainFrame::OnCreateControl (in the CommandBars sample "MDIMenus").<br>What this code is intended to do is hide the menu items "Print Setup" (in the "File" popup menu) and "Blue" (in the "Color" popup menu).<br>The effect is: only "Print Setup" is hidden, "Blue" is still visible.<br><br>int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)<br>{<br>&nbsp; ...<br>&nbsp; ...<br>&nbsp; if (lpCreateControl-&gt;nID == ID_FILE_PRINT_SETUP)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; // exclude only IDR_MDIMENUTYPEHTML template<br>&nbsp;&nbsp;&nbsp; // this code is reached because for the "File" popup menu, SetCommandBar(pPopupMenu) is NOT called<br>&nbsp;&nbsp;&nbsp; CXTPControl *pControl = (CXTPControl*)CXTPControlButton::CreateObject();<br>&nbsp;&nbsp;&nbsp; pControl-&gt;AssignDocTemplate(IDR_MDIMENUTYPEHTML);<br>&nbsp;&nbsp;&nbsp; lpCreateControl-&gt;pControl = pControl;<br>&nbsp;&nbsp;&nbsp; return TRUE;<br>&nbsp; }<br>&nbsp; if (lpCreateControl-&gt;nID == ID_COLOR_BLUE)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; // exclude only IDR_MDIMENUTYPEHTML template<br>&nbsp;&nbsp;&nbsp; // this code is never called because for the "Color" popup menu, SetCommandBar(pPopupMenu) IS called<br>&nbsp;&nbsp;&nbsp; CXTPControl *pControl = (CXTPControl*)CXTPControlButton::CreateObject();<br>&nbsp;&nbsp;&nbsp; pControl-&gt;AssignDocTemplate(IDR_MDIMENUTYPEHTML);<br>&nbsp;&nbsp;&nbsp; lpCreateControl-&gt;pControl = pControl;<br>&nbsp;&nbsp;&nbsp; return TRUE;<br>&nbsp; }<br>&nbsp; return FALSE;<br>}<br><br><br>I guess that's a bug in the Xtreme Toolkit.<br><br>Nevertheless, in the meantime I luckily managed to create a work-around. I created a new class MyXTPControlPopup derived from CXTPControlPopup and added a second parameter to the SetCommandBar method:<br><br>void MyXTPControlPopup::SetCommandBar(CMenu* pMenu, CXTPCommandBars *pCommandBars)<br>{<br>&nbsp; if (!m_pCommandBar)<br>&nbsp;&nbsp;&nbsp; m_pCommandBar = CXTPPopupBar::CreatePopupBar(pCommandBars);<br><br>&nbsp; m_pCommandBar-&gt;LoadMenu(pMenu);<br>}<br><br>For comparison see the original code below:<br>void CXTPControlPopup::SetCommandBar(CMenu* pMenu)<br>{<br>&nbsp;&nbsp;&nbsp; if (!m_pCommandBar)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; m_pCommandBar = CXTPPopupBar::CreatePopupBar(m_pParent ? m_pParent-&gt;GetCommandBars() : NULL);<br><br>&nbsp;&nbsp;&nbsp; m_pCommandBar-&gt;LoadMenu(pMenu);<br>}<br><br><br>In CMainFrame::OnCreateControl, I now can create an instance of type MyXTPControlPopup and call &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pControlPopup-&gt;SetCommandBar(pPopupMenu, GetCommandBars());<br>instead of<br>&nbsp; &nbsp; &nbsp; pControlPopup-&gt;SetCommandBar(pPopupMenu);<br><br>Now it works because the GetOwnerSite / GetSite now always return the CMainFrame pointer.<br><br>Perhaps you can try to reproduce. If you are able to reproduce the bug I will make a bug report.<br><br>Thank you, Michael<br>]]>
   </description>
   <pubDate>Tue, 22 May 2007 08:09:58 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23152&amp;title=oncreatecontrol-not-called-for-menu-items#23152</guid>
  </item> 
  <item>
   <title><![CDATA[OnCreateControl not called for menu items : Hi,  Strange. it have call it...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23140&amp;title=oncreatecontrol-not-called-for-menu-items#23140</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 7199<br /><strong>Posted:</strong> 22 May 2007 at 1:03am<br /><br /><DIV>Hi,</DIV><DIV>&nbsp;</DIV><DIV>Strange. it have call it for all controls. What toolkit vesrion do you have? </DIV>]]>
   </description>
   <pubDate>Tue, 22 May 2007 01:03:49 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23140&amp;title=oncreatecontrol-not-called-for-menu-items#23140</guid>
  </item> 
  <item>
   <title><![CDATA[OnCreateControl not called for menu items : Hi Oleg and team,I&amp;#039;m rather...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23125&amp;title=oncreatecontrol-not-called-for-menu-items#23125</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3014">mschumi</a><br /><strong>Subject:</strong> 7199<br /><strong>Posted:</strong> 21 May 2007 at 2:28pm<br /><br />Hi Oleg and team,<br><br>I'm rather new with the Xtreme Toolkit (VisualStudio 2005). What I'm trying to do is hide whole popup menus and also single menu items (depending on the MDI template).<br><br>To achieve this, I'm handling the ON_XTP_CREATECONTROL message quite similar as is done in the CommandBars sample MDIMenus:<br><br>int CMainFrame::OnCreateControl(...)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (lpCreateControl-&gt;strCaption == _T("&amp;Window"))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CXTPControlPopup* pControlPopup = CXTPControlPopup::CreateControlPopup(xtpControlPopup);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Exclude only IDR_MAINFRAME template<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pControlPopup-&gt;ExcludeDocTemplate(IDR_MAINFRAME);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // from here AddMenuItem is called for the non-popup menu subitems<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pControlPopup-&gt;SetCommandBar(pPopupMenu);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lpCreateControl-&gt;pControl = pControlPopup;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>Hiding of the first-level popup menus works very well, however for the menu's sub-items, OnCreateControl is not called. <br>As far as I could see, <br>SetCommandBar calls CXTPControls::AddMenuItem<br>(via CXTPCommandBar::LoadMenu, CXTPControls::LoadMenu).<br><br>In AddMenuItem, a CWnd* pSite is determined. That is where the WM_XTP_BEFORECREATECONTROL is sent (should be CMainFrame).<br><br>However, when AddMenuItem is called for a (non-popup) sub-item, pSite is NULL.<br>The problem is reproducable in the MDIMenus sample also (although there only popup menus are handled).<br><br>Do you have any suggestions?<br><br>Thanks a lot, Michael<br><br>  ]]>
   </description>
   <pubDate>Mon, 21 May 2007 14:28:33 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=7199&amp;PID=23125&amp;title=oncreatecontrol-not-called-for-menu-items#23125</guid>
  </item> 
 </channel>
</rss>