
-----------------------------------
Siavash
Mon May 25, 2009 9:38 pm

changing screen size using corners of the run window
-----------------------------------
ive seen many tutorials on how to change screen size like the fallowing:

setscreen ('graphics:maxx,maxy')

But how do i allow the user make the screen larger by dragging the corners of the run window?

-----------------------------------
DtY
Mon May 25, 2009 9:57 pm

RE:changing screen size using corners of the run window
-----------------------------------
As far as I know, you can't

-----------------------------------
Dusk Eagle
Mon May 25, 2009 11:30 pm

Re: changing screen size using corners of the run window
-----------------------------------
You can't do what you wanted, but you can set the screen size using variables, like this:

var x_size := 100
var y_size := 180
View.Set ("graphics:" + intstr(x_size) + "," + intstr(y_size))

So, since this is entirely possible, you could add buttons to your screen that increase or decrease the screen's size. Not sure if this can help you here, but it's an interesting thing to know either way,

-----------------------------------
Kharybdis
Tue May 26, 2009 7:57 am

RE:changing screen size using corners of the run window
-----------------------------------
you can kinda cheat and make this possible... like you can do with anything..

but i wouldn't recommend it. too much work..

-----------------------------------
BigBear
Tue May 26, 2009 9:34 am

Re: RE:changing screen size using corners of the run window
-----------------------------------
you can kinda cheat and make this possible... like you can do with anything..

but i wouldn't recommend it. too much work..

How is it cheating, you can't drag the corners with the mouse but you can figure out a way of using turing, isn't that what programming is learning how to use a programming language?

-----------------------------------
Geniis
Wed May 27, 2009 6:02 pm

Re: changing screen size using corners of the run window
-----------------------------------
i made a quick prog to resize the window once. All i did was check if the mouse was on a border or corner then then figured out the difference and set the screens size with setscreen to the old size plus the difference. But whenever i did the window would disappear and reapear so its not worth dooing.

-----------------------------------
DemonWasp
Wed May 27, 2009 9:10 pm

RE:changing screen size using corners of the run window
-----------------------------------
This code demonstrates how this can be done, but as Geniis notes, it destroys and re-creates the window every time you resize it, and it doesn't resize with the cursor (you could also do that, but I didn't). It's also not perfect - if you click your mouse anywhere and drag over that corner, it'll grab it anyway (this is fixable, but I'm lazy).


var x, y : int := 400               % Size of the screen
var mx, my, mb : int                % Mouse status
var dragging : boolean := false     % True if and only if we're dragging the window corner
const TOLERANCE : int := 5          % Tolerance for mouse-click distance, in pixels

fcn nearEquals (a, b, tol : int) : boolean      % Comparator that's essentially "approximately equal to, plus or minus 'tol'".
    result a + tol >= b and a - tol  0 and nearEquals (x, mx, TOLERANCE) and nearEquals (0, my, TOLERANCE) then     % We're clicking near that corner, start dragging
        dragging := true
    elsif mb = 0 and dragging then    % Released, so resize
        dragging := false
        x := mx
        y := maxy-my
        View.Set ("graphics:" + intstr (x) + ";" + intstr (y))
    end if

    % Debugging output
    Text.Locate (1, 1)
    put "x = ", x, "; y = ", y
    put "mx = ", mx, "; my = ", my
    put "dragging = ", dragging
end loop

