Well I decided to go try xFunction. Seems to work pretty well. Here is a sample program that calls Beep :-) and the SystemParametersInfo function to find out the size of the desktop work area -- the part that isn't covered by the task bar.
---------- WinRect.java ----------
import com.excelsior.xFunction.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class WinRect extends Structure {
int left;
int top;
int right;
int bottom;
public String defineLayout() {
return "int left, int top, int right, int bottom";
}
public String toString() {
return "WinRect["+left+","+top+",
}
public static void main(String[] args) {
try {
xFunction f = new xFunction("kernel32", "int Beep(int,int)");
f.invoke(new Argument(1770), new Argument(100));
} catch (Exception e) {
e.printStackTrace();
}
WinRect rect = new WinRect();
System.out.println("Before
try {
/* The following is equivalent to the JNI:
RECT workArea;
SystemParametersInfo(SPI_W
jint width = workArea.right - workArea.left;
jint height = workArea.bottom - workArea.top;
*/
String sig = "int SystemParametersInfoA(int,
xFunction f = new xFunction("user32", sig);
Argument arg1 = new Argument(48);
Argument arg2 = new Argument(0);
Pointer arg3 = Pointer.createPointerTo(re
Argument arg4 = new Argument(0);
Integer val = (Integer)f.invoke(arg1, arg2, arg3, arg4);
rect = (WinRect)arg3.deref();
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
System.out.println("After call: " + rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
System.out.println("Work area = " + width + "x" + height);
JFrame frame = new JFrame("Maximum Work Area");
frame.addWindowListener(ne
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setSize(new Dimension(width, height));
frame.show();
}
}
---------- end ----------
Jim
Main Topics
Browse All Topics





by: jim_cakalicPosted on 2001-01-10 at 21:33:39ID: 101441
My typical answer to this question is "NO". But I've recently come across a couple packages that purport to do exactly that. My caveat is, I've never used these before so I cannot really recommend any of these solutions.
om/xfuncti on.html
java/jcoro /jcoromain .htm
Excelsior xFunction -- Shareware ($99) with 30-day eval download
http://www.excelsior-usa.c
Coroutine -- Freeware
http://www.nevaobject.com/
SWIG (Simplied Wrapper and Interface Generator) -- Free, claims to support Java but that wasn't obvious from the on-line documentation.
http://www.swig.org/
Of these, the first two appear to me like the ones where I plan to spend most of my time in evaluation ... whenever I can get around to it ...
Best regards,
Jim Cakalic