<?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 : Main menu item enabling/disabling</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Command Bars : Main menu item enabling/disabling]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 10 Jun 2026 08:13:05 +0000</pubDate>
  <lastBuildDate>Thu, 30 Nov 2006 05:02:30 +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=5634</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[Main menu item enabling/disabling : Dear Oleg,  Thank you very much....]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17801&amp;title=main-menu-item-enabling-disabling#17801</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2372">sunilwarke</a><br /><strong>Subject:</strong> 5634<br /><strong>Posted:</strong> 30 November 2006 at 5:02am<br /><br />Dear Oleg,<DIV>&nbsp;</DIV><DIV>Thank you very much. I have solved my problem using the solution you gave me.&nbsp; I have learnt more about ON_UPDATE_COMMAND_UI which was new to me.</DIV><DIV>&nbsp;</DIV><DIV>Once again thank you.</DIV><DIV>&nbsp;</DIV><DIV>TR,</DIV><DIV>Sunil Warke</DIV>]]>
   </description>
   <pubDate>Thu, 30 Nov 2006 05:02:30 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17801&amp;title=main-menu-item-enabling-disabling#17801</guid>
  </item> 
  <item>
   <title><![CDATA[Main menu item enabling/disabling : Here steps:  Add member variable...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17791&amp;title=main-menu-item-enabling-disabling#17791</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 5634<br /><strong>Posted:</strong> 30 November 2006 at 1:52am<br /><br />Here steps:<DIV>&nbsp;</DIV><DIV>Add member variable for CMainFrame m_bDatabaseCommandEnabled;</DIV><DIV>&nbsp;</DIV><DIV>Change EnableMenuItem to:</DIV><DIV>&nbsp;</DIV><DIV><DIV>void CMainFrame::EnableMenuItem(BOOL bEanbled)</DIV><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp; m_bDatabaseCommandEnabled = bEanbled;</DIV><DIV>}</DIV><DIV>&nbsp;</DIV><DIV>add handlers for all commands you need:</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>ON_UPDATE_COMMAND_UI(IDC_TOOLBARCOMMAND, OnUpdateToolbarCommand)</DIV><DIV>...</DIV><DIV>void CMainFrame::OnUpdateToolbarCommand(CCmdUI* pCmdUI)<BR>{</DIV><DIV>pCmdUI-&gt;Enable(m_bDatabaseCommandEnabled );</DIV><DIV>}<BR></DIV><DIV>&nbsp;</DIV></DIV>]]>
   </description>
   <pubDate>Thu, 30 Nov 2006 01:52:06 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17791&amp;title=main-menu-item-enabling-disabling#17791</guid>
  </item> 
  <item>
   <title><![CDATA[Main menu item enabling/disabling : Dear Mr. Oleg    Thank you...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17754&amp;title=main-menu-item-enabling-disabling#17754</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2372">sunilwarke</a><br /><strong>Subject:</strong> 5634<br /><strong>Posted:</strong> 29 November 2006 at 6:42am<br /><br />Dear Mr. Oleg<DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Thank you for your reply. I have looked at the CommandBar folder for the similar sample code but I did not find the specific one.</DIV><DIV>&nbsp;</DIV><DIV>In my application, there are 4 child windows and the Menu enabling and disabling is not depend on the child selection or creation. The menu items shall be enabled or disabled on some event (coming from database). So I have written a function which shall enable or disable menu items based on the event. </DIV><DIV>&nbsp;</DIV><DIV>On creation some controls will be enabled and some of them shall be disabled. </DIV><DIV>&nbsp;</DIV><DIV>Can you point out specific example for me? Or can you please send me a sample code like a function. </DIV><DIV>&nbsp;</DIV><DIV>void EnableMenuItem(True)</DIV><DIV>{</DIV><DIV>&nbsp;&nbsp;&nbsp; GetMenu()</DIV><DIV>&nbsp;&nbsp;&nbsp; EnableItem(Id, enable);</DIV><DIV>&nbsp;&nbsp;&nbsp; Update();</DIV><DIV>}</DIV><DIV>&nbsp;</DIV><DIV>My problem is to get the pointer to the Menu so that I can enable/disable the item based on the Id.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>TR,</DIV><DIV>Sunil</DIV>]]>
   </description>
   <pubDate>Wed, 29 Nov 2006 06:42:04 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17754&amp;title=main-menu-item-enabling-disabling#17754</guid>
  </item> 
  <item>
   <title><![CDATA[Main menu item enabling/disabling : Hello,  Use Update handlers....]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17750&amp;title=main-menu-item-enabling-disabling#17750</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 5634<br /><strong>Posted:</strong> 29 November 2006 at 6:09am<br /><br />Hello,<DIV>&nbsp;</DIV><DIV>Use Update handlers. See any sample from CommandBars folder.</DIV>]]>
   </description>
   <pubDate>Wed, 29 Nov 2006 06:09:49 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17750&amp;title=main-menu-item-enabling-disabling#17750</guid>
  </item> 
  <item>
   <title><![CDATA[Main menu item enabling/disabling : Hi,  I have the following code,...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17747&amp;title=main-menu-item-enabling-disabling#17747</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2372">sunilwarke</a><br /><strong>Subject:</strong> 5634<br /><strong>Posted:</strong> 29 November 2006 at 5:46am<br /><br /><DIV>Hi,</DIV><DIV>&nbsp;</DIV><DIV>I have the following code, I want to enable and disable some menu buttons on creating MDI application. But wherever I call GetMenu, it always return NULL and the program crashes. </DIV><DIV>&nbsp;</DIV><DIV>Can anybody tell me how to enable or disable the Main Menu controls when using CXTPCommandBars?</DIV><DIV>&nbsp;</DIV><DIV>I tried several options to get the control on the Menu buttons but could not succeeded. If anybody knows how to do it especially in MDI application then please let me know.</DIV><DIV>&nbsp;</DIV><DIV>Here is the code</DIV><DIV>-----------------------------------------------------------------------------------------</DIV><DIV>// Get a pointer to the command bars object.<BR>&nbsp;CXTPCommandBars* pCommandBars = GetCommandBars();<BR>&nbsp;if(pCommandBars == NULL)<BR>&nbsp;{<BR>&nbsp;&nbsp;TRACE0("Failed to create command bars object.\n");<BR>&nbsp;&nbsp;return -1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // fail to create<BR>&nbsp;}</DIV><DIV>&nbsp;// Add the menu bar<BR>&nbsp;CXTPCommandBar* pMenuBar = pCommandBars-&gt;SetMenu(<BR>&nbsp;&nbsp;_T("TIS Menu Bar"), IDR_MDI_TYPE);<BR>&nbsp;if(pMenuBar == NULL)<BR>&nbsp;{<BR>&nbsp;&nbsp;TRACE0("Failed to create menu bar.\n");<BR>&nbsp;&nbsp;return -1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // fail to create<BR>&nbsp;}</DIV><DIV>&nbsp;// System popup menu<BR>&nbsp;pMenuBar-&gt;SetFlags(xtpFlagAddMDISysPopup);</DIV><DIV>&nbsp;// Create ToolBar<BR>&nbsp;CXTPToolBar* pToolBar = (CXTPToolBar*)<BR>&nbsp;&nbsp;pCommandBars-&gt;Add(_T("Standard"), xtpBarTop);<BR>&nbsp;if (!pToolBar || !pToolBar-&gt;LoadToolBar(IDR_MDI_MAIN))<BR>&nbsp;{<BR>&nbsp;&nbsp;TRACE0("Failed to create toolbar\n");<BR>&nbsp;&nbsp;return -1;<BR>&nbsp;}</DIV><DIV>&nbsp;</DIV><DIV>CMenu *mymenu = pMenuBar-&gt;GetMenu();</DIV><DIV>//CMenu *mymenu = GetMenu();</DIV><P>&nbsp;CString temp, temp1 = "";<BR>&nbsp;if(mymenu-&gt;GetMenuItemCount() &gt; 0)<BR>&nbsp;{<BR>&nbsp;&nbsp;for(int j = 0; j &lt; mymenu-&gt;GetMenuItemCount(); j++)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;mymenu-&gt;GetMenuStringA(j, temp, MF_BYPOSITION);<BR>&nbsp;&nbsp;&nbsp;temp1.Append(temp);<BR>&nbsp;&nbsp;}</P><P>&nbsp;&nbsp;::MessageBox(NULL, temp1, "Count ok", MB_OK);</P><P>&nbsp;}<BR>-----------------------------------------------------------------------------------------</P><DIV></DIV><DIV></DIV>TR,<DIV>Sunil</DIV>]]>
   </description>
   <pubDate>Wed, 29 Nov 2006 05:46:47 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=5634&amp;PID=17747&amp;title=main-menu-item-enabling-disabling#17747</guid>
  </item> 
 </channel>
</rss>