Older Version Newer Version

JanetTerra JanetTerra Dec 3, 2009

The original explanation and code was written by - JohnDavidson JohnDavidson and can be found in this thread at the Just BASIC Forums.

Try running this demo and hit the maximize/restore button.
Notice the coordinates in each button. They are specified differently for each corner.

    nomainwin
 
    WindowWidth = 380
    WindowHeight = 240
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)
 
    button #1.b1, "Upper Left",  [p], UL, 26, 16, 90, 25
    button #1.b2, "Upper Right", [p], UR, 26, 16, 90, 25
    button #1.b3, "Lower Left",  [p], LL, 26,  0, 90, 25
    button #1.b4, "Lower Right", [p], LR, 80, 16, 90, 25
 
    open "untitled" for window as #1
    print #1, "trapclose [quit.1]"
    print #1, "font MS_Sans_Serif 8"
[p]
    wait
 
[quit.1]
    Close #1
    END 

Note that you cannot use the same values for UL, UR, LL, and LR and expect the buttons to be evenly distanced from each corner.