Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to get menu bar handle?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to get menu bar handle?

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


Joined: 28 November 2008
Location: Belarus
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote arty Quote  Post ReplyReply Direct Link To This Post Topic: How to get menu bar handle?
    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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
arty View Drop Down
Newbie
Newbie


Joined: 28 November 2008
Location: Belarus
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote arty Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pad_32 View Drop Down
Newbie
Newbie


Joined: 02 December 2008
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote pad_32 Quote  Post ReplyReply Direct Link To This Post 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
 
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.207 seconds.