Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Accessing Delphi forms in DLLs

843829Jun 6 2002 — edited Jun 19 2002
Hello all,

I have the following problem:
I want to use an existing Delphi form in a DLL.
The wrapper code has been created using JavaToDPR (http://home.pacifier.com/~mmead/jni/delphi/JavaToDPR), a javah-like tool for Object Pascal.

The DLL loads all-right and calls from Java to Delphi methods are OK.
When it comes to displaying the form, though, here comes trouble!

The form is displayed "frozen" (no dragging, no mouse events, no repainting).
This causes all of the application to rfuse to terminate normally (via System.exit()), so I have to Ctrl+C the Java window.

I suspect it has something to do with how Delphi "understands" the calling process, although I am not sure. Note, that I have tested the simple DLL with a Delphi application and everything is OK.

Have you experienced similar problems with other languages (e.g. VB/VC++ DLL form)?
Does anyone have any idea why this might occur and it could be solved?

Any help is grealy appreciated.

Thank you for your time,

Stelios

// ---- code for NativeCaller.java ----
package delphitest;
...
// shows a Windows alert message box
public native void showMessage(String message);
// shows a Delphi form
public native void showForm(String caption);
...

// ---- code for Delphi project -----
library NativeCaller;

// the exported methods are here
uses
Main in 'Main.pas' {Form1};
// the exported methods
exports
Java_delphitest_NativeCaller_showMessage,
Java_delphitest_NativeCaller_showForm;

begin
end.

// --- code for Delphi form ----
unit Main;
// import the JNI.pas which contains the Java2Delphi bridge code
uses
JNI, Windows,...;
...
// forward declarations
procedure Java_delphitest_NativeCaller_showMessage(PEnv: PJNIEnv; Obj: JObject; Arg1: JString); stdcall; export;
procedure Java_delphitest_NativeCaller_showForm(PEnv: PJNIEnv; Obj: JObject; Arg1: JString); stdcall; export;
...
// shows a Win alert dialog, works very well
procedure Java_delphitest_NativeCaller_showMessage(PEnv: PJNIEnv; Obj: JObject; Arg1: JString); stdcall; export;
begin
MessageDlg('Hello!', mtWarning, mbOKCancel, 0);
end;
...
// shows the form, the form is displayed "frozen"
procedure Java_delphitest_NativeCaller_showForm(PEnv: PJNIEnv; Obj: JObject; Arg1: JString); stdcall; export;
begin
temp := TForm1.Create(nil);

temp.Show();
temp.Update();
end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2002
Added on Jun 6 2002
2 comments
546 views