September 11th, 2003, 04:08 AM
Last Hope! C++ and the API from HELL!
I have asked this question all over the place and have not got any response, so this is my last hope.
I am using the API AccessibleObjectFromWindow( ... ) to find the menu bar of an office application. I am using this function in conjunction with the OBJID_NATIVEOM param to get the native object model of the commandbar. The function works and returns S_OK. The problem is that the object returned is an IAccessible* I use query interface to see the object supports the command bar interface and low and behold it doesn't. By examining the object returned I can see that it is the command bar because it has all of the properties. i.e. Name, Role, even position.
If anyone knows how to get this to work I would be very grateful if you could explain how. Any suggestion, tips or comments would be appreciated.
Just for reference here is a very very cut down version of the code. It is hosted in a C++ Com DLL that is being called by a VB.Net Client (I know VB.Net isn't the best choice of client, but they are making me use it because they "canít afford to re-train staff to uses C++")
STDMETHODIMP CUtils::GetMenu(IDispatch** ppMenu)
IDispatch * pDisp = NULL;
HWND hWnd = FindWindowEx(GetDesktopWindow(), NULL, "wndclass_desked_gsk",NULL);
hWnd = FindWindowEx(hWnd, NULL, "MsoCommandBarDock", "MsoDockTop");
hWnd = FindWindowEx(hWnd, NULL, "MsoCommandBar", "MenuBar");
AccessibleObjectFromWindow(hWnd, OBJID_NATIVEOM, IID_IDispatch, (void**) ppMenu);
September 11th, 2003, 06:25 AM
I know absolutely nothing about the Win32 API but the folks HERE can probably help you.
September 11th, 2003, 06:57 AM