Jump to content
Excelsior Forums

konczcsj

Members
  • Content count

    0
  • Joined

  • Last visited

    Never

Community Reputation

0 Neutral

About konczcsj

  • Rank
    Newbie
  • Birthday 01/01/01
  1. SetTimer in user32.dll

    I am evaluating xFunction and I tried to use the timer services of user32.dll. I wrote a class Timer with the following code: [pre] import com.excelsior.xFunction.*; import javax.swing.*; public class Timer { public static void main(String[] a) { try { Callback timerCallback = new TimeoutCallback(); xFunction f = new xFunction("user32","int SetTimer(int,int,int,TimeoutCallback)"); Argument[] args = new Argument[4]; args[0] = new Argument(0); //no window handle args[1] = new Argument(0); args[2] = new Argument(5000); //wait for 5 seconds args[3] = new Argument(timerCallback); int i = ((Integer)f.invoke(args)).intValue(); System.out.println(" Timer Handle = " + i); //without the lines below the program exits immediatelly JFrame frame = new JFrame("SetTimer test"); frame.setSize(100,100); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } } class TimeoutCallback extends Callback{ public String defineSignature(){ return "void timeout(int,int,int,long)"; } public void timeout(int a, int b, int c, long d){ System.out.println("Timeout received!"); } } [/pre] Although the return value indicates success (i get a non-null timer ID), no call is made to my callback. What am I doing wrong here?
×