FreeBasic has enough functions/keywords to make your own GUI as you go along.
Code: Select all
screenres 400,600,32
color ,rgb(236,233,216)
windowtitle "ADD UP"
dim as integer numboxes=3
dim shared as string t(1 to numboxes),j(1 to numboxes)
type box
as integer x,y,w,h
as uinteger col
as zstring ptr s
end type
function inbox(x as integer,y as integer,b as box) as integer
return x>b.x and x<(b.x+b.w) and y>b.y and y<(b.y+b.h)
end function
sub drawbox(b as box)
line(b.x,b.y)-(b.x+b.w,b.y+b.h),b.col,bf
line(b.x,b.y)-(b.x+b.w,b.y+b.h),b.col/2,b
draw string(b.x+2,b.y+4),*b.s,rgb(0,0,0)
end sub
Sub _input(i as string,x As Integer,y As Integer,st As String,message As String,clr As Uinteger=Rgb(0,0,0),flag as integer=1)
Static As Integer count,gap=20
Static As String blink
count=count+1 Mod 100
If Left(i,1)=Chr(08) Then j(flag)=Mid(j(flag),1,Len(j(flag))-1)
Select Case Left(i,1)
Case Chr(0) To Chr(254)
If Left(i,1)<>Chr(08) Then
j(flag)=j(flag)+Left(i,1)
End If
End Select
If count Mod gap=0 Then blink=" "
If count Mod 2*gap=0 Then blink="_"
If Left$(i,1)=Chr(27) Then j(flag)=""
Draw String(x+2,y+4),st & i & blink,clr
message=mid(j(flag),1,25)
End Sub
var Input1=type<box>(48,80,200,30,rgb(255,255,255),@" ")
var Input2=type<box>(48,280,200,30,rgb(255,255,255),@" ")
var answer=type<box>(48,480,200,30,rgb(236,233,216),@" ")
dim as integer mx,my,mb,bb,cc
dim as string i
do
i=inkey
if i=chr(256)+"k" then end
getmouse mx,my,,mb
screenlock
cls
drawbox(Input1):drawbox(Input2):drawbox(answer)
if mb=1 then bb=inbox(mx,my,Input1) :cc=inbox(mx,my,Input2)
if bb then _input(i,Input1.x,Input1.y,*Input1.s,t(1),,1):Input1.s=@t(1)[0]
if cc then _input(i,Input2.x,Input2.y,*Input2.s,t(2),,2):Input2.s=@t(2)[0]
var sumf=(val(*Input2.s)+val(*Input1.s))
draw string(answer.x,answer.y-16),"Answer:",rgb(0,0,0)
draw string(answer.x+2,answer.y+4),"" &sumf,rgb(0,0,0)
screenunlock
sleep 1,1
loop