<?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 : Regarding Enabling/Disableing Menu</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : Regarding Enabling/Disableing Menu]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Sat, 04 Apr 2026 03:50:00 +0000</pubDate>
  <lastBuildDate>Mon, 30 Apr 2007 04:58:20 +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=6981</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[Regarding Enabling/Disableing Menu : Hi Oleg,  Thank you very much...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22447&amp;title=regarding-enabling-disableing-menu#22447</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 30 April 2007 at 4:58am<br /><br /><DIV>Hi Oleg,</DIV><DIV>&nbsp;</DIV><DIV>Thank you very much for your great support and responce.</DIV><DIV>&nbsp;</DIV><DIV>We will surely discuss the issue for using "OnInitCommandBarsPopup()" with our team.</DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>KumarCJ.</DIV>]]>
   </description>
   <pubDate>Mon, 30 Apr 2007 04:58:20 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22447&amp;title=regarding-enabling-disableing-menu#22447</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : void CMainFrame::OnInitCommandsPopup(CXTPPopupBar*...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22444&amp;title=regarding-enabling-disableing-menu#22444</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 30 April 2007 at 4:03am<br /><br /><DIV>void CMainFrame::OnInitCommandsPopup(CXTPPopupBar* pCommandBar)<BR>{</DIV><DIV>&nbsp;&nbsp;int nCount = pCommandBar-&gt;GetControls()-&gt;GetCount();</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;for (int i = 0; i &lt; nCount; i++)<BR>&nbsp;{</DIV><DIV>CXTPControl* pCommandNew =&nbsp;&nbsp;pCommandBar-&gt;GetControl(i)<BR>&nbsp;&nbsp; if (pCommandNew-&gt;GetID() == ID_EDIT_CUT)<BR>&nbsp;&nbsp; {</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pCommandNew-&gt;SetEnabled(FALSE);</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>pCommandBarNew-&gt;SetFlags(xtpFlagManualUpdate);<BR></strong>&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#006633>}</FONT></DIV><DIV>&nbsp;&nbsp;&nbsp;}</DIV><DIV>&nbsp;}<BR></DIV><DIV>&nbsp;</DIV><DIV>Also check "Samples\CommandBars\ActionsSample" sample - if you don't want update handlers, you can use actions </DIV><DIV>&nbsp;</DIV><DIV>pCommandBars-&gt;GetActions()-&gt;FindAction(ID_EDIT_CUT)-&gt;SetEnabled(FALSE);</DIV><DIV>&nbsp;</DIV><DIV>again - don't use OnInitCommandBarsPopup for changing state - its very bad design. There is no pattern for such design.</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Mon, 30 Apr 2007 04:03:50 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22444&amp;title=regarding-enabling-disableing-menu#22444</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi,  wating for your valuable...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22441&amp;title=regarding-enabling-disableing-menu#22441</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 30 April 2007 at 2:37am<br /><br />Hi,<DIV>&nbsp;</DIV><DIV>wating for your valuable suggestion.</DIV><DIV>&nbsp;</DIV><DIV>I had mention the issue in code what you sent it to me in prvious post.</DIV><DIV>&nbsp;</DIV><DIV>Please let me know the solution for that. </DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>KumarCJ</DIV>]]>
   </description>
   <pubDate>Mon, 30 Apr 2007 02:37:37 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22441&amp;title=regarding-enabling-disableing-menu#22441</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi Oleg,   Thanks for your...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22407&amp;title=regarding-enabling-disableing-menu#22407</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 8:29am<br /><br />Hi Oleg,<DIV></DIV><DIV></DIV><DIV>Thanks for your great suggestion.</DIV><DIV><DIV></DIV><DIV></DIV>When&nbsp;I placed the code what you sent it giving the error below:</DIV><DIV>&nbsp;</DIV><DIV></DIV><DIV></DIV><DIV></DIV>error C2039: 'SetEnable' : is not a member of 'CXTPControl'<DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>Then I searched for <strong>SetEnable() </strong>in the help, and I found <strong>SetEnabled()&nbsp;</strong>in <strong>CXTPControl class. </strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV><FONT color=#990000>Then i tried&nbsp;with <FONT color=#000000><strong>SetEnabled () </strong>in the </FONT>following code,</FONT></DIV><DIV><FONT color=#990000></FONT>&nbsp;</DIV><DIV><strong>void CMainFrame::OnInitCommandsPopup(CXTPPopupBar* pCommandBar)<BR></strong>{</DIV><DIV>&nbsp;&nbsp; CXTPControl* <strong>pCommandNew</strong> = pCommandBar-&gt;GetControls()-&gt;FindControl(xtpControlButton, ID_EDIT_CUT, TRUE, FALSE);<BR>&nbsp;</DIV><DIV>//CXTPControl* <strong>pCommandNew</strong> = pCommandBar-&gt;GetControls()-&gt;FindControl(xtpControlPopup, ID_EDIT_CUT, TRUE, FALSE);<BR></DIV><DIV>&nbsp;int nCount = pCommandBar-&gt;GetControls()-&gt;GetCount();</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;for (int i = 0; i &lt; nCount; i++)<BR>&nbsp;{<BR>&nbsp;&nbsp; if (pCommandBar-&gt;GetControl(i)-&gt;GetID() == ID_EDIT_CUT)<BR>&nbsp;&nbsp; <strong>pCommandNew</strong>-&gt;<strong>SetEnabled</strong>(FALSE);<BR><strong>&nbsp;&nbsp; <FONT color=#006633>//&#091;Comment out due to error mentioned above&#093;</FONT></strong></DIV><DIV>&nbsp;&nbsp; <FONT color=#009933>//pCommandBar-&gt;GetControl(i)-&gt;SetEnable(FALSE);<BR></FONT>&nbsp;&nbsp;&nbsp;}</DIV><DIV>&nbsp;}<BR></DIV><DIV><strong><FONT color=#ff0000>But the ISSUE remains the same?</FONT></strong></DIV><DIV>&nbsp;</DIV><DIV>What need to be done for this Oleg????</DIV><DIV>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>KumarCJ</DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 08:29:45 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22407&amp;title=regarding-enabling-disableing-menu#22407</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi, catch  OnInitCommandsPopup(CXTPPopupBar*...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22401&amp;title=regarding-enabling-disableing-menu#22401</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 6:46am<br /><br /><DIV></DIV>Hi, catch <DIV><strong>OnInitCommandsPopup(CXTPPopupBar* pCommandBar)</strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV><strong>loop all controls and check IDS of them:</strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV><strong>nCount = pCommandBar-&gt;GetControls()-&gt;GetCount();</strong></DIV><DIV><strong>for (int i = 0;i &lt; nCount; i++<BR>{</strong></DIV><DIV><strong>&nbsp; if (pCommandBar-&gt;GetControl(i)-&gt;GetID() == ID_EDIT_CUT)</strong></DIV><DIV><strong>&nbsp;&nbsp;&nbsp; pCommandBar-&gt;GetControl(i)-&gt;SetEnable(FALSE);</strong></DIV><DIV><strong>}</strong></DIV><DIV><strong>etc.</strong></DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 06:46:04 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22401&amp;title=regarding-enabling-disableing-menu#22401</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi Oleg,  Thanks you very much...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22400&amp;title=regarding-enabling-disableing-menu#22400</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 6:20am<br /><br /><DIV>Hi Oleg,</DIV><DIV>&nbsp;</DIV><DIV>Thanks you very much for your seggestions and help.</DIV><DIV>&nbsp;</DIV><DIV>Yes I do understand it is not good idea to implement <strong><FONT color=#993300>WM_INITMENUPOPUP, </FONT></strong><strong>but </strong>as we are following design patterns and handling all the enabling/disabling menu item in a single class, which required <strong><FONT color=#ff0000>nIndex</FONT>, </strong>which we&nbsp;were getting in <SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: #993300; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN; mso-fareast-font-family: 'Times New Roman'; mso-fareast-: EN-US; mso-bidi-: AR-SA"><FONT color=#993300><strong>OnInitMenuPopup()</strong> </FONT></SPAN>function's 2nd parapameter.</DIV><DIV>&nbsp;</DIV><DIV><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><SPAN>Is there any way to get <strong>nIndex (determine on which menu&nbsp;user clicks)</strong></SPAN><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN">, so that I have to make few changes with changing the desgin pattern.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#ff0000>Is there any other way to handle this ISSUE????</FONT></DIV><DIV><FONT color=#ff0000></FONT>&nbsp;</DIV><DIV><FONT color=#ff0000>Waiting for your valuable suggestion.</FONT></DIV><DIV><FONT color=#ff0000></FONT>&nbsp;</DIV><DIV><FONT color=#ff0000>Thanks,</FONT></DIV><DIV><FONT color=#ff0000>KumarCJ.</FONT></DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 06:20:03 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22400&amp;title=regarding-enabling-disableing-menu#22400</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hello,  This is _very_ bad idea...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22390&amp;title=regarding-enabling-disableing-menu#22390</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 3:56am<br /><br /><DIV>Hello,</DIV><DIV>&nbsp;</DIV><DIV>This is _very_ bad idea to use WM_INITMENUPOPUP to enable/disable state for some controls. users can customize menu and move Cut Command from one menu to another - to copy this menu to toolbar, delete it&nbsp;etc. </DIV><DIV>&nbsp;</DIV><DIV>as I wrote use Update handlers for IDs:</DIV><DIV>in message map of your view add:</DIV><DIV>&nbsp;</DIV><DIV>ON_UPDATE_COMMAND_UI(ID_ED_CUT, OnUpdateCut)</DIV><DIV>&nbsp;</DIV><DIV>void CYourView::OnUpdateCut(CCmdUI* pCmdUI)<BR>{<BR>&nbsp;pCmdUI-&gt;Enable(m_bNeedToEnable);<BR>}</DIV><DIV>&nbsp;</DIV><DIV>it will work with your old application/new appliaction and any future applications.<BR></DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 03:56:12 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22390&amp;title=regarding-enabling-disableing-menu#22390</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi Oleg,  Our application follows...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22385&amp;title=regarding-enabling-disableing-menu#22385</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 3:18am<br /><br />Hi Oleg,<DIV>&nbsp;</DIV><DIV><FONT color=#990066>Our application follows standard View/Document architecture,</FONT> <strong>We do not have handler for cut,copy,paste and find in our OLDER version of application as well as NEW version of Application.</strong></DIV><DIV>&nbsp;</DIV><DIV>we are just using "<FONT color=#993300>ON_WM_INITMENUPOPUP()" </FONT>message <SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN; mso-fareast-: EN-US; mso-bidi-: AR-SA">in older version of our application</SPAN>. </DIV><DIV>&nbsp;</DIV><DIV>For&nbsp;above mentioned message we are having Handler</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#993300>"void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)"</FONT></DIV><DIV><DIV>&nbsp;</DIV><DIV>So when user click on any of the menu, <FONT color=#990000>MFC framework fills nIndex = 2 </FONT>(<strong>Assume&nbsp;user selected EDIT Menu</strong>).</DIV><DIV>&nbsp;</DIV><DIV>This&nbsp; nIndex value we are passing to <SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: #993300; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-: EN; mso-fareast-: EN-US; mso-bidi-: AR-SA">OnInitMenuPopup() </SPAN>function with aother parameters such as&nbsp;&nbsp;window handle, Menu Handle, etc</DIV><DIV>&nbsp;</DIV><DIV><FONT color=#993300>MyApp_OnInitMenuPopup(m_hWnd, hMenu, nIndex, 0L);</FONT></DIV><DIV>&nbsp;</DIV><DIV>In this function based on certain condition we are enabling/disabling menu items.</DIV><DIV>&nbsp;</DIV><DIV><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><B style="mso-bidi-font-weight: normal"><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: maro&#111;n; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN">The Above mentioned flow is for OLDER as well as NEWER version of our application.</P><P =Ms&#111;normal style="MARGIN: 0in 0in 0pt"><?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></B></P></DIV><DIV><DIV>Assume Edit Menu Contail following Menu Items:</DIV></DIV><DIV><FONT color=#990000>Cut, Copy, Paste, Find</FONT></DIV><DIV><FONT color=#990000><strong>AddRecord</strong></FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#ff0000><strong>When we were using below lines of code</strong></FONT></DIV><DIV><FONT color=#ff0000></FONT>&nbsp;</DIV><DIV>CXTPMenuBar* m_wndMenuBar = pCommandBars-&gt;SetMenu(_T("Menu Bar"), IDR_MAINFRAME);</DIV><DIV>&nbsp;</DIV><DIV><strong>All Menu Item get Enabled,&nbsp; means cut,copy,paste and AddRecord are in ENABLED state.</strong></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#ff0000><strong>But when&nbsp;we are using&nbsp;OLD code, Menu Item are displaying&nbsp;fine</strong></FONT>. </DIV><DIV>&nbsp;</DIV><DIV><strong><FONT color=#000000>Means Cut,Copy, Paste, Find are in DISABLED state&nbsp;and AddRecord menu item is in ENABLED state.</FONT></strong></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><strong><FONT color=#ff0000>So What I should do for this to overcome this issue....?</FONT></strong></DIV><DIV>&nbsp;</DIV><DIV>I went through the Notification Sample and tried with following handlers</DIV><DIV>OnCreateCommandBar</DIV><DIV>OnCreateControl</DIV><DIV>OnAfterCreateControl</DIV><DIV>OnCustomize</DIV><DIV>OnInitCommandsPopup</DIV><DIV>&nbsp;</DIV><DIV>What I understand from this that as soon as we used SetMenu(), Program control&nbsp;is not comeing to "<FONT color=#993300>OnInitMenuPopup</FONT>", but when i tried with <strong>OnInitCommandsPopup()</strong> and when user click on Menu, the Control is comming to "<strong>OnInitCommandsPopup()".</strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV>Is there any way to get the <strong>nIndex </strong>by using </DIV><DIV><strong>OnInitCommandsPopup(CXTPPopupBar* pCommandBar)</strong></DIV><DIV>&nbsp;</DIV><DIV><strong>Please help me out in this ISSUE.</strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV><strong>Waiting for your kind suggetions.</strong></DIV><DIV><strong></strong>&nbsp;</DIV><DIV>Thanks,</DIV><DIV>KumarCJ.</DIV></DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 03:18:26 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22385&amp;title=regarding-enabling-disableing-menu#22385</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hello,  Do you use standard...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22377&amp;title=regarding-enabling-disableing-menu#22377</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=6851">Oleg</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 27 April 2007 at 1:10am<br /><br />Hello,<DIV>&nbsp;</DIV><DIV>Do you use standard View/Document architecture? By defaul they have to be disabled if you don't have handlers for them. if you have handlers - just add also Update handlers and enable/disable them in this handler - not in <FONT color=#993300>OnInitCommandsPopup.</FONT></DIV>]]>
   </description>
   <pubDate>Fri, 27 Apr 2007 01:10:49 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22377&amp;title=regarding-enabling-disableing-menu#22377</guid>
  </item> 
  <item>
   <title><![CDATA[Regarding Enabling/Disableing Menu : Hi Oleg,  Thanks for your reply.  I...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22354&amp;title=regarding-enabling-disableing-menu#22354</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=2903">KumarCJ</a><br /><strong>Subject:</strong> 6981<br /><strong>Posted:</strong> 26 April 2007 at 8:22am<br /><br />Hi Oleg,<DIV>&nbsp;</DIV><DIV>Thanks for your reply.</DIV><DIV>&nbsp;</DIV><DIV>I had trying with the <FONT color=#000033><strong>OnInitCommandsPopup()</strong> given in Notification sample.</FONT></DIV><DIV><FONT color=#000033></FONT>&nbsp;</DIV><DIV>I trapped "ON_XTP_INITCOMMANDSPOPUP()" i.e.<FONT color=#000033> OnInitCommandsPopup() function.</FONT></DIV><DIV>&nbsp;</DIV><DIV><FONT color=#993300>void CMainFrame::OnInitCommandsPopup(CXTPPopupBar* pCommandBar)<BR><strong>{</strong></FONT></DIV><DIV><FONT color=#993300>&nbsp;&nbsp;</FONT></DIV><DIV><FONT color=#993300>&nbsp; &nbsp;// get the list of commands for the popup.<BR>&nbsp;&nbsp; CXTPControls* pCommandList = pCommandBar-&gt;GetControls();</FONT></DIV><DIV><FONT color=#993300>&nbsp;</FONT></DIV><DIV><FONT color=#993300>&nbsp;&nbsp; CMenu* pPopupMenu;<BR></FONT><FONT color=#993300>&nbsp;&nbsp; CMainFrame * pMainFrame = (CMainFrame *)AfxGetMainWnd();<BR>&nbsp;&nbsp; pPopupMenu = CMenu::FromHandle(pMainFrame-&gt;hMenuHandle);</FONT></DIV><DIV><FONT color=#993300></FONT>&nbsp;</DIV><DIV><FONT color=#993300>&nbsp;&nbsp; //Get Menu Handle</FONT>&nbsp;</DIV><DIV><FONT color=#993300>&nbsp;&nbsp; HMENU hMenu = pPopupMenu-&gt;GetSafeHmenu();</FONT></DIV><DIV><FONT color=#993300>&nbsp;</FONT></DIV><DIV><FONT color=#993300>&nbsp;&nbsp; //<strong>MyApp_OnInitMenuPopup(m_hWnd, hMenu, <FONT color=#ff0000>nIndex</FONT>, 0L);</strong></FONT></DIV><DIV><strong><FONT color=#993300></FONT></strong>&nbsp;</DIV><DIV><strong><FONT color=#ff0000>&nbsp;&nbsp; &#091;Note: For Edit Menu, hard coded nIndex = 2&#093;</FONT></strong></DIV><DIV><strong><FONT color=#ff0000></FONT></strong>&nbsp;</DIV><DIV><FONT color=#993300><strong>&nbsp;&nbsp;&nbsp;</strong><SPAN lang=EN style="FONT-SIZE: 9pt; COLOR: maro&#111;n; FONT-FAMILY: Verdana; mso-bidi-font-family: 'Times New Roman'; mso-ansi-: EN">Pim_OnInitMenuPopup(m_hWnd, hMenu, 2, 0L);<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></FONT></DIV><DIV><FONT color=#993300><strong>}</strong></FONT></DIV><DIV><FONT color=#993300></FONT>&nbsp;</DIV><DIV><DIV><FONT color=#000033>But the issue is that i need to pass the <strong><FONT color=#ff0000>"nIndex"</FONT> </strong>parameter to <FONT color=#993300><strong>MyApp_OnInitMenuPopup(m_hWnd, hMenu, <FONT color=#ff0000>nIndex</FONT>, 0L) function.</strong></FONT></FONT></DIV><DIV><strong><FONT color=#993300></FONT></strong>&nbsp;</DIV><DIV><FONT color=#000033>How I can get the <strong>"nIndex" </strong>when i clicked on menu i.e. for Edit menu it 2, for view it is 3.</FONT></DIV><DIV><FONT color=#000033></FONT>&nbsp;</DIV><DIV><FONT color=#000033>nIndex is&nbsp;the Menu Index i.e on which menu user clicks.</FONT></DIV><DIV><FONT color=#993300></FONT>&nbsp;</DIV><DIV><FONT color=#333333>I had <strong>hard coded </strong>the <strong>nIndex to 2 i.e for Edit Menu </strong>and tried, the function <strong><FONT color=#993300>MyApp_OnInitMenuPopup() is going fine,</FONT></strong>&nbsp;</FONT></DIV><DIV><FONT color=#333333></FONT>&nbsp;</DIV><DIV><FONT color=#ff0000>but finally after clicking on <strong>EDIT</strong> menumenu Item such as Cut, Copy, paste are enabled eventhough there is no active child window.</FONT></DIV><DIV><strong></strong>&nbsp;</DIV><DIV><strong><FONT color=#ff0000>&#091;Question 1:&#093;</FONT></strong></DIV><DIV><strong><FONT color=#ff0000></FONT></strong>&nbsp;</DIV><DIV><strong><FONT color=#ff0000>How can i get "nIndex" using </FONT><FONT color=#993300>OnInitCommandsPopup(CXTPPopupBar* pCommandBar)???</FONT><BR></strong></DIV><DIV><strong><FONT color=#ff0000>&#091;Question 2:&#093;</FONT></strong></DIV><DIV><strong><FONT color=#ff0000></FONT></strong>&nbsp;</DIV><DIV><strong><FONT color=#333333>If I hard coded the nIndex = 2 for Edit Menu and </FONT><FONT color=#993300>MyApp_OnInitMenuPopup() </FONT></strong><FONT color=#333333>is going fine, then why Cut, Copy, Paste is <strong>not disabled. Is there any more messages&nbsp;i need to do add???</strong></FONT></DIV><DIV><strong><FONT color=#ff0000></FONT></strong>&nbsp;</DIV><DIV><strong><FONT color=#333333>Waiting for&nbsp;reply.</FONT></strong></DIV><DIV><strong><FONT color=#333333></FONT></strong>&nbsp;</DIV><DIV><FONT color=#333333>Thanks,</FONT></DIV><DIV><FONT color=#333333>KumarCJ</FONT></DIV><DIV><strong><FONT color=#333333></FONT></strong>&nbsp;</DIV></DIV>]]>
   </description>
   <pubDate>Thu, 26 Apr 2007 08:22:10 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=6981&amp;PID=22354&amp;title=regarding-enabling-disableing-menu#22354</guid>
  </item> 
 </channel>
</rss>