views:

339

answers:

2

In a Java application (JRE 1.5.0_12) on Windows XP, I call a native method:

public native int attachImage( ... );

... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this window has focus. This is an issue because when this window is displayed, users often switch to another application to select the image to attach, then want to restore this application.

A: 

What GUI package are you using?

You should be able to implement this without resorting to JNI calls.

For instance, in SWT, you can open an application modal shell like this:

Shell shell = new Shell(display,SWT.APPLICATION_MODAL);

For swing, this would be:

dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
James Van Huis
I agree, however this is legacy code. Short of a complete rewrite of the native components, I'm stuck with what I've got.
Bob Kaufman
A: 

Does your attachImage method not properly set the parent window to your java application window? Getting a hwnd for that could be tricky (GetForegroundWindow/etc?) but it might be necessary?

Also, why does the image part need to be JNI? that might help us find you a solution that avoids the JNI part altogether?

John Gardner