ok well I'm making a set of functions for making windows forms(kinda like magic windows but more windows looking) and i have buttons and moving the forms around. but if you click on one form and theres a button behind it on another form it will click it.
Right now the form priority is set up by the number of the form. but it still has the button clicking problem lol I'm not sure what to do.
i wish there was a set sprite priority command for dbc

lol
heres a screeny and the update window code
function Update forms(X)
if forms(X)=1
Sprite (X+600),formx(X),FormY(X),X+600
set sprite (X+600),1,0
if mouseclick()
if move=0
if on title(X)
move=X
endif
endif
if move=X
if first=0
diffx=mouseX()-formX(X)
diffY=MouseY()-formY(X)
first=1
endif
formX(X)=mouseX()-diffX
formY(X)=MouseY()-DiffY
move=X
endif
endif
X1=FormX(X)+ClosebuttonX(X)
X2=FormX(X)+ClosebuttonX(X)+11
Y1=FormY(X)+1
Y2=FormY(X)+11
if mouseclick() and mouseinside(X1,Y1,X2,Y2)
sprite (X+50),X1,Y1,802
set sprite (X+50),1,0
Repeat : sync : until mouseclick()=0
if mouseinside(X1,Y1,X2,Y2) then Close form(X)
else
sprite (X+50),X1,Y1,801
set sprite (X+50),1,0
endif
if mouseclick()=0 then move=0 : title=0 : first=0
for y=1 to 50
if buttons(x,y)=1
if mouseclick() and on button(x,y)
sprite (Y+700),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,1)
set sprite (Y+700),1,0
else
sprite (Y+700),buttonX(x,y)+FormX(X),buttonY(X,Y)+FormY(X),buttonimg(x,y,0)
set sprite (Y+700),1,0
endif
endif
next y
endif
endfunction
any other ideas would be appreciated also

btw if you want the hole code i can attach it (no media required)