Timer in DWT?

Sam Hu samhu.samhu at gmail.com
Mon Sep 8 17:41:42 PDT 2008


Hi Frank,

For example,I want to draw a line of text on the form which indicate the current date and time,very second it changes.Below is the code I tried,when I run the program,the drawn text does not change every second if I won't resize the form.I think it is the canvas.redraw method which is the problem,but I don't know which method shoud I use instead.
//*************************
 Display display=new Display;
 Shell shell=new Shell(display);
 Canvas canvas=new Canvas(shell,DWT.NONE);
 canvas.addPaintListener(new class PaintListener{
    public void paintControl(PaintEvent e)
    {
       auto layout=new Locale;
			
      e.gc.drawText(layout("{:ddd,dd MMMM yyyy HH':'mm':'ss z}",
				WallClock.now),100,100);
    }
 });

display.getCurrent.timerExec( 500, dgRunnable({
						
					canvas.redraw;
  }));

//*****************************

Please help.Thanks.

Sam


More information about the Digitalmars-d-dwt mailing list