1

Another basic problem - I can't convert a Process.MainWindowHandle to an HWND. I've tried using Process->MainWindowHandle.ToPointer() and passing that through, but still no love.

Here is a function that gets an HWND from a Point, and then passes that though, and it works perfectly.

void echoMouseObject() {
long vmID;
AccessibleContext acParent;
AccessibleContext ac;
POINT p;
HWND hwnd;
RECT windowRect;

GetCursorPos(&p);
hwnd = WindowFromPoint(p);
if (GetAccessibleContextFromHWND(hwnd, &vmID, &acParent)) {
    GetWindowRect(hwnd, &windowRect);
    // send the point in global coordinates; Java will handle it!
    if (GetAccessibleContextAt(vmID, acParent, (jint) p.x, (jint) p.y, &ac)) {
        displayAccessibleInfo(vmID, ac, p.x, p.y);      // can handle null
        ReleaseJavaObject(vmID, ac);
    }
}

However, when I pass GetAccessibleContextFromHWND() in the following manner, where win_handle is declared in this manner:

HWND win_handle;

and it's assigned a value by:

Process^ p = gcnew Process();
p = getJavaProcess();
JA->setWindow((HWND)p->MainWindowHandle.ToPointer());
JA->test();

void JavaAccess::test(void)
{
    long vm=0;
    AccessibleContext* ac = new AccessibleContext();
    BOOL t = GetAccessibleContextFromHWND(win_handle, &vm, ac);
    AccessibleContextInfo* aci = new AccessibleContextInfo();
    GetAccessibleContextInfo(vm, *ac, aci);
}

I get a false! The function fails to return a valid vmID, or accessibleContext. What on earth? :-S

getJavaProcess() is just a function that sorts through the Processes and returns the one that matches the criteria I've defined.

I have succesfully hooked the Java Access Bridge callbacks, and they return/trigger as expected, so I know that the Bridge is loading alright. I can also call getVersionInfo(vmID) from within a callback, and it works as expected. I'm so confused.

HeWhoWas
  • 601
  • 1
  • 10
  • 22
  • The rules that GetMainWindowHandle() uses to *guess* at the process' main window are not solid. It is easily tripped up by things like a splash screen. Use Spy++ to verify the window handle value. – Hans Passant Sep 27 '11 at 03:57
  • The Process.MainProcessHandle is correct. Both Spy++ and my Application both read the same value (Currently 0x00050AF0). – HeWhoWas Sep 27 '11 at 04:14

0 Answers0