<?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 : How to enable or disable the toolbar buttons?</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : How to enable or disable the toolbar buttons?]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 22 Apr 2026 10:21:33 +0000</pubDate>
  <lastBuildDate>Sun, 11 Jan 2009 12:17:13 +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=13137</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[How to enable or disable the toolbar buttons? : CXTPToolBar* pToolbar = pComma...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44440&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44440</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 11 January 2009 at 12:17pm<br /><br />CXTPToolBar* pToolbar = pCommandBars-&gt;GetToolBar(IDR_TOOLBAR_START); // here I get NULL (I don't know why because the toolbar is created when I call this) - This is very bad situation&nbsp;- it means that you created temporary object which disapear later (like you leave a scoop?)<DIV>I need to modify the MFC source code afxpriv.h ? - No, you just use some private MFC feature </DIV>]]>
   </description>
   <pubDate>Sun, 11 Jan 2009 12:17:13 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44440&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44440</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : Hi,   CXTPCommandBars* pCommandBars...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44439&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44439</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3171">evoX</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 11 January 2009 at 10:51am<br /><br />Hi, <DIV>&nbsp;&nbsp; C<FONT size=2>XTPCommandBars* pCommandBars = GetCommandBars(); // This returns the correct pointer <P>&nbsp;&nbsp; CXTPToolBar* pToolbar = pCommandBars-&gt;GetToolBar(IDR_TOOLBAR_START); // here I get NULL (I don't know why because the toolbar is created when I call this)</P></FONT></DIV><DIV>&nbsp;<FONT size=2>CXTPToolBar* pToolbar = pCommandBars-&gt;GetAt(0); // This will return a correct pointer !</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV>&nbsp; why do I need to add OnKickIdle in the property page? because the toolbar is in the propertysheet in place of the standard wizard buttons.</DIV><DIV>&nbsp;&nbsp; I need to modify the MFC source code afxpriv.h ?</DIV><DIV>&nbsp;</DIV><DIV>Thanks !</DIV>]]>
   </description>
   <pubDate>Sun, 11 Jan 2009 10:51:26 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44439&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44439</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : this is that you need: Using...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44437&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44437</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 11:55pm<br /><br />this is that you need:<DIV>Using ON_UPDATE_COMMAND_UI message maps in property pages is the same as in dialogs except for one extra step required. <BR>You need to derive a class from CPropertySheet and intercept the WM_KICKIDLE messages.</DIV><DIV>1. Create a new class called CMyPropSheet with a base class of CPropertSheet.<BR>2. In the header add the message function. afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM, LPARAM);<BR>3. In the source file #include afxpriv.h<BR>4. Add the message map ON_MESSAGE(WM_KICKIDLE, OnKickIdle)<BR>5. Implement the function.</DIV><DIV>LRESULT CMyPropSheet::OnKickIdle(WPARAM, LPARAM)<BR>{<BR>&nbsp;SendMessageToDescendants(WM_WM_KICKIDLE, 0, 0, FALSE, FALSE);<BR>&nbsp;return 0;<BR>}</DIV><DIV>The property sheet now passes all WM_KICKIDLE message to its property pages.<BR>&nbsp;<BR>In the property page class, just add a message map for WM_KICKIDLE and call UpdateDialogControls. </DIV><DIV>LRESULT CMyPropPage::OnKickIdle(WPARAM, LPARAM)<BR>{<BR>&nbsp;UpdateDialogControls(this, FALSE);<BR>&nbsp;return 0L;<BR>}</DIV><DIV>Then all you need is ON_UPDATE_COMMAND_UI message maps.</DIV><DIV>P.S. This does not work for modeless property sheets. You need to trap the WM_IDLEUPDATECMDUI message in the property sheet's owner window and send it WK_KICKIDLE messages.</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 23:55:11 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44437&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44437</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : void CMainPropertySheet::OnUpdateMenuStart(CCmdUI*...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44436&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44436</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 11:36pm<br /><br /><DIV>void CMainPropertySheet::OnUpdateMenuStart(CCmdUI* pCmdUI)<BR>{<BR>&nbsp;&nbsp; pCmdUI-&gt;Enable(!m_bTaskRunning);<BR>}<BR></DIV><DIV>ProperySheets - Wizards have little bit another handling - look in any sample where you have "Finish" button which disable until some condition</DIV><DIV>&nbsp;</DIV><DIV>I gave you some standard ideas for SDI - MDI architecture</DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 23:36:05 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44436&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44436</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : Same story: you don&amp;#039;t check if...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44435&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44435</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 10:48pm<br /><br />Same story: you don't check<DIV>if (GetCommandBars()-&gt;GetToolBar(IDR_TOOLBAR_START))</DIV><DIV>{</DIV><DIV>&nbsp;</DIV><DIV>}</DIV><DIV>I guess it give NULL</DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 22:48:51 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44435&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44435</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : I used ON_UPDATE_COMMAND_UI, but...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44434&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44434</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3171">evoX</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 10:40pm<br /><br /><P>I used ON_UPDATE_COMMAND_UI, but now the problem is that the button remains disabled forever because ON_UPDATE_COMMAND_UI is called only when you press the button</P><DIV>(and yes, the m_bTaskRunning is set correctly&nbsp;to FALSE after the task is finished, but the toolbar button still remains disabled)</DIV><DIV>&nbsp;</DIV><DIV>void CMainPropertySheet::OnUpdateMenuStart(CCmdUI* pCmdUI)<BR>{<BR>&nbsp;if (m_bTaskRunning == TRUE) pCmdUI-&gt;Enable(FALSE);<BR>&nbsp;else pCmdUI-&gt;Enable(TRUE);<BR>}<BR></DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 22:40:04 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44434&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44434</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : well I don&amp;#039;t think that it&amp;#039;s...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44433&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44433</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3171">evoX</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 10:23pm<br /><br />well I don't think that it's my dirty programming style, because even with this line it crashes<DIV>CXTPControl* pBarControl = GetCommandBars()-&gt;GetToolBar(IDR_TOOLBAR_START)-&gt;GetControl(0);//0=New, 1=Open and so on<BR></DIV><DIV>&nbsp;</DIV><DIV>It crashes in this XTP function with access violation</DIV><DIV>int CXTPCommandBar::GetControlCount() const<BR>{<BR>&nbsp;return m_pControls-&gt;GetCount();<BR>}</DIV><DIV>&nbsp;</DIV><DIV>I will try to use ON_UPDATE_COMMAND_UI</DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 22:23:37 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44433&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44433</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : You can access individual toolbar...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44432&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44432</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 9:14pm<br /><br />You can access individual toolbar button or other elements with:<DIV><FONT size=2><P>CXTPControl* pBarControl = GetCommandBars()-&gt;GetToolBar(IDR_MAINFRAME)-&gt;GetControl(1);</FONT><FONT color=#008000 size=2>//0=New, 1=Open and so on</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (pBarControl)</P><P>pBarControl-&gt;SetEnabled(FALSE);</P><DIV>BUT IT WILL NOT HELP YOU as System will enable it because you don't like to use&nbsp; ON_UPDATE_COMMAND_UI and by default all will be enable again</DIV><DIV>while code</DIV><DIV><FONT color=#0000ff size=2><P>void</FONT><FONT size=2> CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI)</P><P>{</P><P>pCmdUI-&gt;Enable(FALSE);</P><P>}</P><DIV></DIV>do proper work</FONT></DIV></FONT></DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 21:14:29 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44432&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44432</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : You crashing problems related...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44431&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44431</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=4721">mdoubson</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 8:33pm<br /><br />You crashing problems related to your dirty programming style:<DIV><FONT size=2>I am sure you have no GetCommandBars()-&gt;GetToolBar(0) at all </FONT></DIV><DIV><FONT size=2>You don't&nbsp;check it before asking action:</FONT></DIV><DIV><FONT size=2>if (GetCommandBars()-&gt;GetToolBar(0))</FONT></DIV><DIV><FONT size=2>{</FONT></DIV><DIV><FONT size=2>&nbsp;&nbsp; GetCommandBars()-&gt;GetToolBar(0)-&gt;SetVisible(FALSE);</FONT></DIV><DIV><FONT size=2><P>&nbsp;&nbsp; GetCommandBars()-&gt;GetToolBar(0)-&gt;SetContextMenuPresent(FALSE);</P></FONT></DIV><DIV><FONT size=2>}</FONT></DIV><DIV><FONT size=2></FONT>&nbsp;</DIV><DIV><FONT size=2>e.g. for most app this code will works</FONT></DIV><DIV><FONT size=2>GetCommandBars()-&gt;GetToolBar(IDR_MAINFRAME)-&gt;SetVisible(FALSE);</DIV></FONT>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 20:33:02 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44431&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44431</guid>
  </item> 
  <item>
   <title><![CDATA[How to enable or disable the toolbar buttons? : If I use this, the application...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44429&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44429</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3171">evoX</a><br /><strong>Subject:</strong> 13137<br /><strong>Posted:</strong> 10 January 2009 at 3:50pm<br /><br /><P>If I use this, the application crashes</P><FONT size=2><P>GetCommandBars()-&gt;GetToolBar(0)-&gt;SetVisible(FALSE);</P><DIV></DIV><DIV>Also the I think that SetVisible will completly hide the toolbar which is not what I want.&nbsp; I just want the buttons to be disabled.</DIV><DIV></FONT>&nbsp;</DIV>]]>
   </description>
   <pubDate>Sat, 10 Jan 2009 15:50:56 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=13137&amp;PID=44429&amp;title=how-to-enable-or-disable-the-toolbar-buttons#44429</guid>
  </item> 
 </channel>
</rss>