开发者

.NET Handle to HWND

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜