Print Page | Close Window

How to get menu bar handle?

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=12815
Printed Date: 06 May 2024 at 1:27am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to get menu bar handle?
Posted By: arty
Subject: How to get menu bar handle?
Date Posted: 28 November 2008 at 9:11am
Oleg, please could you help me. I have a task to emulate a call of menu item (in dynamic menu) in third-party application which uses codejock toolkit. I’m a newbie at C++ but here is my plan. With help of Spy++ I found out that I can SendMessage to the main window with WM_COMMAND and wID. And it works! But at the moment I can’t get a wID (for testing I used wID from Spy). So then I used EnumChildWindows for getting all controls and tried to get menu handle with GetMenu

Remarks from MSDN: GetMenu does not work on floating menu bars. Floating menu bars are custom controls that mimic standard menus; they are not menus. To get the handle on a floating menu bar, use the Active Accessibility APIs.

and AccessibleObjectFromWindow. But every time I’ve received null. Is there another way to do that?



Replies:
Posted By: Oleg
Date Posted: 01 December 2008 at 4:40am
HI,
 
Its not that easy :( our Menus have no HMENU handles. But indeed can try Accessibility feature that we support. You have call AccessibleObjectFromWindow for Menu window - see it in Spy++ - its window with XTPToolBar class.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: arty
Date Posted: 01 December 2008 at 6:32am
BOOL CALLBACK // callback for EnumChildWindows
EnumChildProc(HWND hwnd, LPARAM lParam)
{
  IDispatch** ppMenu;
  AccessibleObjectFromWindow(hwnd, OBJID_NATIVEOM, IID_IDispatch, (void**) ppMenu);
  // ppMenu is always null (even when hwnd=000103BE)
  return TRUE;
}


Here is code I use to get menu. As you see AccessibleObjectFromWindow is called for every child in window. I tried to insert OBJID_MENU instead of OBJID_NATIVEOM like dwObjectID parameter and IID_IAccessible instead of IID_IDispatch, but result is “te je yaica, vid sboku”.


Window with handle 000103B0 is main window.
Window with handle 000103BE is my menu I need to get access.


Posted By: Oleg
Date Posted: 02 December 2008 at 2:35am
Hi,
 
I see it has class name "Afx:004..." it means it _very_ old version that didn't support accesibility :-(


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: pad_32
Date Posted: 04 December 2008 at 9:58pm
Hi,
 
One of our client application is using Xtreme command bars. Its version is 8.7.0.0 . Is there any method to know the menu item status (Disable/Enable) programmatically from another application
 



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