I am struggling with this too, and just found a solution that really makes sense. I had to create a debug version of WindowsAccessBridge.dll and use a debugger to enter it to see what was happening.
- A call to 'initializeAccessBridge' REQUIRES to have an active Windows message pump.
Inside 'initializeAccessBridge', it (in the end) creates a hidden dialog box (using CreateDialog). After creating the dialog, it runs PostMessage with the registered message. The JavaVM side of the access bridge responds to this message and sends another message back to the created dialog (it looks like a hello handshake between your application and the Java virtual machine). Thus, if your application does not have an active message pump, the response message from JavaVM will never be received by your application.
This is important, because until this message is received, the bridge will never be correctly initialized and, as such, all calls to "IsJavaWindow" will fail (inside the bridge will initialize the internal structure after receiving the message - as such, there is no active pump messages, without initialization). I guess that is why you never receive callback messages.
Not only that, but you must call initializeAccessBridge at the moment the message pump can process messages before you can call IsJavaWindow.
This is why JavaFerret and JavaMonkey work β they are initialized at startup and then listed when the menu message is answered, and also after the bridge receives the initialization message through the message pump.
The way I was able to solve this in my MFC dialog application (and our MFC-based application) is for you to call "initializeAccessBridge" at such a point that the pump integrated in the MFC message can click "hello" hidden dialogue before you use it. In a simple MFC dialog box, this meant calling initializeAccessBridge on OnInitDialog and calling the enumeration procedure in response to a button call (for example). If you want the enumeration to appear immediately after the dialog box appears, you can use the timer to start (for example, 10 ms) after the OnInitDialog completes, to enable the processing of the initialization message.
If you plan to use this in a console application, you will need to write your own message pump to process the initialization message.
In any case, I hope this is clear enough! Although there is no way to find out if this is the βrightβ way (other than to pay for a Sun engineer to tell us), this definitely solved my problem.
Cheers - Darren.
about. and btw, I found an obscure Sun page that mentioned something that AccessBridge only works for awt-based java applications (but given that Sun hasn't updated any documentation since 2004, this could change). I am not a Java programmer. For testing, I grabbed a number of free Java applications (as well as those that were bundled with jdk), and tried out a test application. It worked for all the ones I tried - YMMV. Good luck