$INCLUDE "windowssdk.inc" WINDOW w1 int CaptionH = GetSystemMetrics(4) int BorderW = GetSystemMetrics(5) int AdjustH = CaptionH - 22 'Window caption height - base number of 22 int Movement = 2 'Amount to move up/down/left/right OPENWINDOW w1,0,0,500,400,@MINBOX|@MAXBOX|@SIZE|@CAPTION,0,"Window",&handler setcaption w1,"Caption " + str$(CaptionH) + " Border " + str$(BorderW) CONTROL w1,@BUTTON,"Button",200,150,50,50,0,1 WAITUNTIL IsWindowClosed(w1) SUB handler(),INT SELECT @MESSAGE CASE @IDCREATE CENTERWINDOW w1 CASE @IDCLOSEWINDOW CLOSEWINDOW w1 CASE @IDCONTROL SELECT @CONTROLID ENDSELECT case @IDKEYDOWN int MOwl, MOwt, Moww, Mowh int MOl, MOt, MOw, MOh GETSIZE w1, MOwl, MOwt, Moww, Mowh GETSIZE w1, MOl, MOt, MOw, MOh,1 int DiffX = MOl-MOwl int DiffY = MOt-MOwt 'if 1 <> 0 'Clicked on a control if @CODE = 38 'UP setsize w1,(MOl-MOwl-8),(MOt-MOwt-30)-Movement,50,50,1 'Up endif if @CODE = 40 'Down setsize w1,(MOl-MOwl-8),(MOt-MOwt-30)+Movement,50,50,1 'Down endif if @CODE = 39 'Right setsize w1,(MOl-MOwl-8)+Movement,(MOt-MOwt-30)-AdjustH,50,50,1 'Right endif if @CODE = 37 'Left setsize w1,(MOl-MOwl-8)-Movement,(MOt-MOwt-30)-AdjustH,50,50,1 'Left endif 'endif ENDSELECT RETURN 0 ENDSUB