Hey this is awesome! Really nice job with the windows.
However, I can't help but feel your program is missing something...
Sync on
Type oWindow
w as integer
h as integer
x as integer
y as integer
title as string
img as integer
dragging as integer
prio as integer
Endtype
Global Windows
Global MXX
Global MYY
Global GrapX
Global GrapY
Global DraggingMarking
Global MarkDragX
Global MarkDragY
Global highestprio
Global DirSelected
Dim Window(0) as oWindow
CreateWindowImages()
Create Bitmap 1,11,11
Ink RGB(0,128,255),RGB(0,128,255)
Box 0,0,10,10
Ink RGB(255,255,255),RGB(255,255,255)
Line 0,10,0,0
Line 0,10,10,10
Line 0,0,10,0
Line 10,0,10,11
Line 0,3,10,3
Get image 4,0,0,11,11
Delete Bitmap 1
MakeWindow(4,"Test Window",10,10,640,480)
MakeWindow(4,"Test Window2",50,50,640,480)
MakeWindow(4,"Test Window3",200,200,100,300)
MakeWindow(4,"[SHOW FPS]",300,300,300,300)
Do
MXX=Mousex()
MYY=Mousey()
If MYY>Screen Height()-25 then MYY=Screen Height()-27
Ink 0,0
Box 0,0,screen width(),screen height()
Ink RGB(255,255,255),RGB(255,255,255)
CheckKeys()
DrawDir()
HandleWindows()
DrawTaskBar()
If Rnd(1000) = 1 then Goto BlueScreen
fastsync
Loop
Function HandleWindows()
For wina=0 to windows-1
If Window(wina).prio>0
LowestPrio=999
For wina2=0 to windows-1
if Window(wina2).prio>0
if Window(wina2).prio<LowestPrio and Window(wina2).prio>oldPrio then LowestPrio=Window(wina2).prio:win=wina2
endif
Next wina2
oldPrio=LowestPrio
img=Window(win).img:title$=Window(win).title
x=Window(win).x:y=Window(win).y
w=Window(win).w:h=Window(win).h
Box x,y,x+w,y+h+15
For yi=y to y+15
ink rgb(0, 128, 255),rgb(0, 128, 255-yi)
Line x,yi,x+w+3,yi
Next yi
ink rgb(0, 128, 192),rgb(0, 128, 192)
y=y+15
For mx=x to x+2
Line mx,y,mx+w,y
Line mx,y,mx,y+h+1
For yi=1 to 3
Line mx,y+h+yi,mx+w+1,y+h+yi
Next yi
Line mx+w,y,mx+w,y+h+2
Next mx
ink rgb(255, 255, 255),rgb(255, 255, 255)
Paste Image Img,x+4,y-13
Paste Image 1,x+w-10,y-13
Paste Image 2,x+w-25,y-13
Paste Image 3,x+w-40,y-13
if window(win).title="[SHOW FPS]" then fpsWin=1:window(win).title="FPS : "+str$(screen fps())
For tx=0 to window(win).w-text width(window(win).title)
Text x+13+(tx*8),y-15,mid$(window(win).title,tx)
Next tx
if fpsWin=1 then window(win).title="[SHOW FPS]":fpsWin=0
HandleMouseEvents(Win)
endif
Next wina
Endfunction
Function DrawDir()
if DirSelected=0 then ink rgb(232, 197, 115),rgb(232, 197, 115):else ink rgb(0, 197, 255),rgb(0, 197, 255)
box 10,10,60,50
if DirSelected=0 then ink rgb(255, 255, 255),rgb(255, 255, 255):else ink rgb(0, 197, 255),rgb(0, 197, 255)
text 10,60,"Windows"
If Mouseclick()
For Win=0 to windows-1
If Window(win).prio>0
If MouseArea(Window(win).x,Window(win).y,Window(win).x+Window(win).w+1,Window(win).y+Window(win).h) then bad=1
endif
Next Win
If bad=0
If MouseArea(10,10,60,50)
If DirSelected=1 then MakeWindow(4,"Windows",400,400,640,480):DirSelected=0
If DirSelected=0 then DirSelected=1
Else
DirSelected=0
Endif
Else
DirSelected=0
Endif
Endif
Ink RGB(255,255,255),RGB(255,255,255)
Endfunction
Function DrawTaskBar()
For y=screen height()-25 to screen height()
ink rgb(0,128,255),rgb(0,128,255-(screen height()-y))
Line 0,y,screen width(),y
Next y
For y=screen height()-25 to screen height()
ink rgb(0,255,128),rgb(0,255-(screen height()-y),128)
Line 0,y,100,y
Next y
Ink 0,0
Circle screen width()-100,Screen height()-12,5
Line screen width()-100,Screen height()-7,screen width()-100,Screen height()
Line screen width()-100,Screen height()-25,screen width()-100,Screen height()-17
ink rgb(255,255,255),rgb(255,255,255)
Line screen width()-102,Screen height()-12,screen width()-97,Screen height()-14
Line screen width()-102,Screen height()-12,screen width()-97,Screen height()-10
box 5,screen height()-20,20,screen height()-5
Text 30,Screen Height()-20,"Start"
Text screen width()-80,screen height()-20,get time$()
if windows>8 then wins=7 else wins=windows-1
For i=0 to wins
If Window(i).prio>0
If Window(i).prio=HighestPrio
Ink Rgb(0, 128, 192),Rgb(0, 128, 192)
Box 120+(x*91),screen height()-23,210+(x*91),screen height()-2
Ink Rgb(255,255,255),Rgb(255,255,255)
Endif
Line 120+(x*91),screen height()-2,210+(x*91),screen height()-2
Line 120+(x*91),screen height()-2,120+(x*91),screen height()-23
Line 120+(x*91),screen height()-23,210+(x*91),screen height()-23
Line 210+(x*91),screen height()-23,210+(x*91),screen height()-2
Paste Image window(i).img,124+(x*91),screen height()-16
if window(i).title="[SHOW FPS]" then fpsWin=1:window(i).title="FPS : "+str$(screen fps())
For tx=0 to 8
Text 127+(x*91)+(tx*8),Screen Height()-20,mid$(window(i).title,tx)
Next tx
if fpsWin=1 then window(i).title="[SHOW FPS]":fpsWin=0
If MouseClick() and DraggingMarking=0 and NoneDragging()
If MouseArea(120+(x*91),screen height()-23,210+(x*91),screen height()-2)
setWinPrio(i)
Endif
Endif
inc x,1
Endif
Next i
Endfunction
Function HandleMouseEvents(Win)
If Mouseclick() and DraggingMarking=0
If MouseArea(Window(win).x+Window(win).w-10,Window(win).y+1,Window(win).x+Window(win).w-1,Window(win).y+13) and NoneDragging()
DestoroyWindow(win)
Endif
If MouseArea(Window(win).x,Window(win).y,Window(win).x+Window(win).w+1,Window(win).y+15) and NoneDragging() or Window(win).Dragging=1
If Window(win).Dragging=0
GrapX=MXX-Window(win).x
GrapY=MYY-Window(win).y
SetWinPrio(win)
Endif
Window(win).x=MXX
Window(win).y=MYY
Window(win).x=Window(win).x-GrapX
Window(win).y=Window(win).y-GrapY
Window(win).Dragging=1
Endif
Endif
If Mouseclick()=0 then Window(win).Dragging=0
Endfunction
Function CheckKeys()
If Mouseclick() and NoneDragging() or DraggingMarking=1
For Win=0 to windows-1
If Window(win).prio>0
If MouseArea(Window(win).x,Window(win).y,Window(win).x+Window(win).w+1,Window(win).y+Window(win).h) then bad=1
Endif
Next Win
If bad=0 or DraggingMarking=1
If DraggingMarking=0
MarkDragX=MXX
MarkDragY=MYY
Endif
Line MarkDragX,MarkDragY,MXX,MarkDragY
Line MarkDragX,MarkDragY,MarkDragX,MYY
Line MXX,MarkDragY,MXX,MYY
Line MarkDragX,MYY,MXX,MYY
DraggingMarking=1
Endif
Endif
If Mouseclick()=0 then DraggingMarking=0
Endfunction
Function FindWindow()
for win=0 to windows-1
if window(win).prio=0 then ok=win
next win
Endfunction ok
Function DestoroyWindow(win)
window(win).prio=0:window(win).dragging=0
Endfunction
Function SetWinPrio(win)
If Window(win).prio>0
For wina=0 to windows-1
if wina<>win
if window(wina).prio>high then high=window(wina).prio
endif
Next wina
window(win).prio=high+1
highestprio=high+1
endif
Endfunction
Function NoneDragging()
For win=0 to windows-1
If Window(win).prio>0
if Window(win).dragging=1 then bad=1
endif
Next win
if bad=1 then ok=0 else ok=1
Endfunction ok
Function MouseArea(x1,y1,x2,y2)
if x1<x2 then first=x1:second=x2:else first=x2:second=x1
if y1<y2 then first2=y1:second2=y2:else first2=y2:second2=y1
If mousex()>first and mousex()<second
If mousey()>first2 and mousey()<second2
ok=1
Endif
Endif
Endfunction ok
Function MakeWindow(Img,Title$,x,y,w,h)
found=FindWindow()
if found>0 then windows=found
if found=0 then Dim Window(windows) as oWindow
Window(windows).img=img:Window(windows).title=title$
Window(windows).x=x:Window(windows).y=y
Window(windows).w=w:Window(windows).h=h
Window(windows).prio=Windows+1:highestprio=Windows+1
if found=0 then Inc windows,1
Endfunction
Function CreateWindowImages()
Create Bitmap 1,11,11
Ink RGB(255,0,0),RGB(255,0,0)
Box 0,0,10,10
Ink RGB(255,255,255),RGB(255,255,255)
Line 7,2,2,7
Line 7,7,2,2
Line 0,10,0,0
Line 0,10,10,10
Line 0,0,10,0
Line 10,0,10,11
Get image 1,0,0,11,11,1
Delete Bitmap 1
Create Bitmap 1,11,11
Ink RGB(0,128,255),RGB(0,128,255)
Box 0,0,10,10
Ink RGB(255,255,255),RGB(255,255,255)
Line 0,10,0,0
Line 0,10,10,10
Line 0,0,10,0
Line 10,0,10,11
Line 2,6,2,2
Line 2,6,6,6
Line 2,2,6,2
Line 6,2,6,7
Get image 2,0,0,11,11,1
Delete Bitmap 1
Create Bitmap 1,11,11
Ink RGB(0,128,255),RGB(0,128,255)
Box 0,0,10,10
Ink RGB(255,255,255),RGB(255,255,255)
Line 0,10,0,0
Line 0,10,10,10
Line 0,0,10,0
Line 10,0,10,11
Line 2,8,7,8
Get image 3,0,0,11,11,1
Delete Bitmap 1
Endfunction
BlueScreen:
For wina=0 to windows-1
DestoroyWindow(wina)
Next wina
Do
Ink RGB(0,0,170),RGB(0,0,170)
Box 0,0,screen width(),screen height()
Ink RGB(170,170,170),RGB(170,170,170)
Center Text 512, 200, "Blue Screen"
Text 250, 250, "A fatal exception 0E has occured at 0137:BFFA21C9. The current"
Text 250, 270, "application will be terminated."
Text 250, 320, "* Press any key to terminate all windows."
Text 250, 340, "* Press ESC to exit the OS. You will"
Text 250, 360, " lose all (un)saved information in all open windows."
Center Text 512, 400, "Press any key to do nothing _"
fastsync
Loop
There we go, makes it feel a bit more "homely", eh?
Seriously though, nice job, are you planning on expanding this further?