Print Page | Close Window

c = GetItemCount(XTPPopup Bar.hwnd)

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=22174
Printed Date: 21 May 2024 at 5:01pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: c = GetItemCount(XTPPopup Bar.hwnd)
Posted By: MrComment
Subject: c = GetItemCount(XTPPopup Bar.hwnd)
Date Posted: 17 January 2014 at 10:47pm
Hi everybody. My first post on the forum.

I have the pleasure of automating an external application via the Windows API thru MS Excel 2007 VBA.Wink

One of the context menus in this application is a Window Class called "XTPPopup Bar".

Which is why I'm here, since a little bit of Googling came short list mostly to CodeJock hits.

Seems like this is as good a place as any to post my problem.
''''''''''''''
Example code:
''''''''''''''
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long

Private Sub Foo_Bar()
Dim hSysMenu As Long, nCnt As Long

hSysMenu = '+ some working code to get the window handle for an active window class "XTPPopup Bar", not shown because its on the other computer.)

nCnt = GetMenuItemCount(hSysMenu)

''''''''''
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.

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.

With that said attempting to return any of the menu strings always comes up blank.

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

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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net