<?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 : c = GetItemCount(XTPPopup Bar.hwnd)</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Command Bars : c = GetItemCount(XTPPopup Bar.hwnd)]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Wed, 13 May 2026 14:05:50 +0000</pubDate>
  <lastBuildDate>Fri, 17 Jan 2014 22:47:38 +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=22174</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[c = GetItemCount(XTPPopup Bar.hwnd) : Hi everybody. My first post on...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=22174&amp;PID=72198&amp;title=c-getitemcountxtppopup-bar-hwnd#72198</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=8634">MrComment</a><br /><strong>Subject:</strong> 22174<br /><strong>Posted:</strong> 17 January 2014 at 10:47pm<br /><br />Hi everybody. My first post on the forum.<br><br>I have the pleasure of automating an external application via the Windows API thru MS Excel 2007 VBA.<img src="http://forum.codejock.com/smileys/smiley2.gif" border="0" alt="Wink" title="Wink" /><br><br>One of the context menus in this application is a Window Class called "XTPPopup Bar".<br><br>Which is why I'm here, since a little bit of Googling came short list mostly to CodeJock hits.<br><br>Seems like this is as good a place as any to post my problem.<br>''''''''''''''<br>Example code:<br>''''''''''''''<br><span ="Reserved">Private</span> <span ="Reserved">Declare</span> <span ="Reserved">Function</span> <span>GetMenuItemCount</span> <span>Lib</span> <span ="">"user32"</span> (<span ="Reserved">ByVal</span> <span>hMenu</span> <span ="Reserved">As</span> <span ="Reserved">Long</span>) <span ="Reserved">As</span> <span ="Reserved">Long<br></span><br><span ="Reserved">Private</span> <span ="Reserved">Sub</span> <span>Foo_Bar</span>()<br><span ="Reserved">Dim</span> <span>hSysMenu</span> <span ="Reserved">As</span> <span ="Reserved">Long</span>, <span>nCnt</span> <span ="Reserved">As</span> <span ="Reserved">Long</span><br><br>hSysMenu = '+ some working code to get the window handle for an active window class "XTPPopup Bar", not shown because its on the other computer.)<br><br><span>nCnt</span> <span ="Operator">=</span> <span>GetMenuItemCount</span>(<span>hSysMenu</span>)<br><br>''''''''''<br>The problem is that when GetMenuItemCount is executed the Result is always -1, so not the number of items in the context menu. Obviously, -1 is an error however the error code is 0.<br><br>As you might of guessed I really dont exactly care how many items are in the context menu. Since my ultimate goal is to find desired command's ID so that I can post a left mouse click to it.<br><br>With that said attempting to return any of the menu strings always comes up blank.<br><br>Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long<br><br>I would prefer to find a way which doesn't require the application to keep focus so that I can post the left mouse click.<br><br>]]>
   </description>
   <pubDate>Fri, 17 Jan 2014 22:47:38 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=22174&amp;PID=72198&amp;title=c-getitemcountxtppopup-bar-hwnd#72198</guid>
  </item> 
 </channel>
</rss>