Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - c = GetItemCount(XTPPopup Bar.hwnd)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

c = GetItemCount(XTPPopup Bar.hwnd)

 Post Reply Post Reply
Author
Message
MrComment View Drop Down
Newbie
Newbie


Joined: 17 January 2014
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrComment Quote  Post ReplyReply Direct Link To This Post Topic: c = GetItemCount(XTPPopup Bar.hwnd)
    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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.