Code: Select all
#define MAXR 2 'max rect
#define MAXW 800 'max width
#define MAXH 600 'max height
#define MINWH 80 'min width/height
#define TBH 25 'titlebar height
type rect
as integer x,y,w,h
as uinteger c
as string title
declare constructor()
declare constructor(as integer,as integer,as integer,as integer,as string,as integer)
declare sub redraw()
end type
constructor rect()
end constructor
constructor rect(x as integer,y as integer,w as integer,h as integer,t as string,c as integer)
this.x = x
this.y = y
this.w = w
this.h = h
this.title = t
this.c = c
redraw()
end constructor
sub rect.redraw()
line(x,y)-(x+w,y+h),&hffffff,BF 'frame
line(x+w-10,y+h-10)-(x+w,y+h),0,BF 'angle
line(x+4,y+TBH)-(x+w-4,y+h-4),c,BF 'box
draw string(x+4,y+8),title
end sub
dim shared as rect r(MAXR)
sub refresh()
screenlock
cls
for i as integer = 0 to MAXR
r(i).redraw()
next i
screenunlock
sleep 1
end sub
screenres MAXW,MAXH,32
color 0,&h3A6EA5
cls
r(0) = rect(10,10,200,140,"Frame 1",&hff0000)
r(1) = rect(40,40,200,140,"Frame 2",&hffff00)
r(2) = rect(80,80,200,140,"Frame 3",&h0000ff)
dim as integer mx,my,mb,x1,y1
do
getmouse mx,my,,mb
x1 = mx
y1 = my
if mb = 1 then
for i as integer = MAXR to 0 step -1
if (mx > r(i).x and mx < r(i).x+r(i).w) and (my > r(i).y and my < r(i).y+r(i).h) then
if i = 1 then
swap r(1),r(2)
elseif i = 0 then
swap r(0),r(1)
swap r(1),r(2)
end if
if i < 2 then refresh()
if mx > (r(2).x + r(2).w - 10) and my > (r(2).y + r(2).h - 10) then
do
getmouse mx,my,,mb
r(2).w += mx - x1
r(2).h += my - y1
x1 = mx
y1 = my
if r(2).w < MINWH then r(2).w = MINWH
if r(2).h < MINWH then r(2).h = MINWH
if r(2).w >= MAXW then r(2).w = MAXW
if r(2).h >= MAXH then r(2).h = MAXH
refresh()
loop until mb = 0
elseif my < (r(2).y + TBH) then
do
getmouse mx,my,,mb
r(2).x += mx - x1
r(2).y += my - y1
x1 = mx
y1 = my
refresh()
loop until mb = 0
end if
exit for
end if
next i
end if
sleep 15,1
loop until multikey(1)
''sleep