do you want to use real win32 gui function - the robk has a blue gui dll that I here works well and will save you alot of trouble.
do you just want to simulate some commands -
heres a menu - for the demo make 2 images face.bmp and icon3.bmp
global menuexists
global textcolor
global menucolor
global menuactive
global messageboxexists
global timer1
`global yes : yes = 1
`global no : no = 0
dim menu$(20)as string
dim itemexists(20)
dim item$(20,20) as string
dim itemactive(20,20)
dim itemchecked(20,20)
dim menuopen(20)
`dim submenu$(20)
spritenumber = 1
spritesize = 50
drawtype = 1
size = 50
color = 0
spriteangle = 0
build_image(31111)
build_image(31112)
`create menus and add items in menus, I limited menus to 10 and items to 10 per menu
`If you need more just change size of the arrays above
`demo usage
`set menu constants
set_menu()
`define menus
create_menu("File")
create_menu_item("File","New")
create_menu_item("File","Open")
create_menu_item("File","Save")
create_menu_item("File","Exit")
set_item("File","Save",0)
set_item("File","Open",0)
create_menu("Drawing")
create_menu_item("Drawing","Circle")
set_item_check("Drawing","Circle",1)
create_menu_item("Drawing","Box")
create_menu_item("Drawing","Line Box")
create_menu("Drawing Size")
create_menu_item("Drawing Size","Bigger")
create_menu_item("Drawing Size","Smaller")
create_menu("Sprite")
create_menu_item("Sprite","Face")
set_item_check("Sprite","Face",1)
create_menu_item("Sprite","DBPro")
create_menu("Sprite Size")
create_menu_item("Sprite Size","Increase")
create_menu_item("Sprite Size","Decrease")
create_menu("Rotate Sprite")
create_menu_item("Rotate Sprite","Left")
create_menu_item("Rotate Sprite","Right")
create_menu("Help")
create_menu_item("Help","About")
set_item_check("Help","About",yes)
`get a blank screen
`get image 1,0,0,screen width(),screen height(),1
load image "face.bmp",1,1
load image "icon3.bmp",2,1
set sprite 1,0,1
sync rate 60
sync on
`create bitmap 1,800,600
`create bitmap 2,800,300
type item
x
y
s
e
c
endtype
dim obj(100) as item
for i = 1 to 100
obj(i).x = rnd(800)
obj(i).y = 0
obj(i).s = rnd(5)+1
obj(i).e = 0
obj(i).c = 0
next i
do
cls
for i = 1 to 100
if obj(i).e = 0 then obj(i).e = 1 : obj(i).y = 0 : obj(i).s = rnd(5)+1 : obj(i).c = rgb(rnd(255),rnd(255),rnd(255))
inc obj(i).y, obj(i).s
if obj(i).y > 800 then obj(i).y = 0 : obj(i).e = 0
`set current bitmap 1
`x = rnd(screen width() - size)
`y = rnd(screen height() - size)
`if color = 0 then ink rgb(rnd(255),rnd(255),rnd(255)),0
ink obj(i).c,0
if drawtype = 1 then circle obj(i).x,obj(i).y,size
if drawtype = 2 then box obj(i).x,obj(i).y,obj(i).x+size,obj(i).y+size
if drawtype = 3 then line_box(obj(i).x,obj(i).y,obj(i).x+size,obj(i).y+size)
next i
sx# = sin(a)*200+400
sy# = cos(a)*200+300
a=a+2
if a = 360 then a = 0
if spritenumber = 1 then rotate sprite 1,spriteangle : size sprite 1,spritesize,spritesize : sprite 1,sx#,sy#,1
if spritenumber = 2 then rotate sprite 1,spriteangle : size sprite 1,spritesize,spritesize : sprite 1,sx#,sy#,2
ink rgb(255,255,0),0
center text screen width()/2,50,"press 'M' to display/undisplay menu"
`set current bitmap 2
ink rgb(255,255,0),0
set cursor 0,200
print screen fps()
display_menu()
if mouse_click_menu() = "New" then text1$ = "menu item" : text2$ = "New" : text3$ = "selected" : messageboxexists = 1
if mouse_click_menu() = "Open" then text1$ = "menu item" : text2$ = "Open" : text3$ = "selected" : messageboxexists = 1
if mouse_click_menu() = "Save" then text1$ = "menu item" : text2$ = "Save" : text3$ = "selected" : messageboxexists = 1
if mouse_click_menu() = "Exit" then end
if mouse_click_menu() = "Circle" then set_item_check("Drawing","Circle",1) : set_item_check("Drawing","Box",0) : set_item_check("Drawing","Line Box",0) : drawtype = 1
if mouse_click_menu() = "Box" then set_item_check("Drawing","Box",1) : set_item_check("Drawing","Circle",0) : set_item_check("Drawing","Line Box",0) : drawtype = 2
if mouse_click_menu() = "Line Box" then set_item_check("Drawing","Line Box",1) : set_item_check("Drawing","Circle",0) : set_item_check("Drawing","Box",0) : drawtype = 3
if mouse_click_menu() = "Bigger" then inc size,1 : if size > 300 then size = 300
if mouse_click_menu() = "Face" then set_item_check("Sprite","Face",1) : set_item_check("Sprite","DBPro",0) : spritenumber = 1
if mouse_click_menu() = "DBPro" then set_item_check("Sprite","Face",0) : set_item_check("Sprite","DBPro",1) : spritenumber = 2
if mouse_click_menu() = "Smaller" then dec size,1 : if size < 20 then size = 20
if mouse_click_menu() = "Increase" then inc spritesize,1 : if spritesize > 300 then spritesize = 300
if mouse_click_menu() = "Decrease" then dec spritesize,1 : if spritesize < 20 then spritesize = 20
if mouse_click_menu() = "Right" then inc spriteangle,1 : if spriteangle > 359 then spriteangle = 0
if mouse_click_menu() = "Left" then dec spriteangle,1 : if spriteangle < 0 then spriteangle = 359
if mouse_click_menu() = "About" then text1$ = "Windows menu Emulator" : text2$ = "version 3.0" : text3$ = "by John Chase" : messageboxexists = 1
if messageboxexists = 1 then message_box(text1$,text2$,text3$)
if scancode() = 50 and timer() - timer1 > 200 then menuactive = 1 - menuactive : timer1 = timer()
`get image 10,0,0,799,219,1
`copy bitmap 1,0
`set current bitmap 0
`paste image 10,0,0,1
sync
loop
`end demo usage
function set_menu()
menuexists = 0
textcolor = rgb(10,10,10)
menucolor = rgb(210,210,210)
menuactive = 1
messageboxexists = 0
endfunction
function set_menu_font(name$)
menufont$=name$
endfunction
function set_item_check(menu$,item$, checked)
for i = 1 to menuexists
if menu$ = menu$(i)
for j = 1 to itemexists(i)
if item$ = item$(i,j) then itemchecked(i,j) = checked
next j
endif
next i
endfunction
function set_item(menu$,item$, active)
for i = 1 to menuexists
if menu$ = menu$(i)
for j = 1 to itemexists(i)
if item$ = item$(i,j) then itemactive(i,j) = active
next j
endif
next i
endfunction
function display_menu()
position = 0
if menuactive = 1
ink menucolor,0
box 0,0,screen width(),18
ink rgb(255,255,255), 0
line_box(0,0,screen width()-1,18)
ink textcolor,0
totalwidth = 0
for i = 1 to menuexists
position = 20 + totalwidth
text position,1,menu$(i)
if menuopen(i) = 1 then open_menu(menu$(i))
inc totalwidth, text width(menu$(i)) + 20
next i
endif
endfunction
function open_menu(name$)
position = 0
for i=1 to menuexists
position = position + text width(menu$(i))+20
if menu$(i) = name$
ink menucolor,0
box position-text width(menu$(i))-20,19,position+100+20-text width(menu$(i)),itemexists(i)*20+15
ink rgb(255,255,255),0
line_box(position-text width(menu$(i))-20,19,position+100+20-text width(menu$(i)),itemexists(i)*20+15)
ink textcolor,0
for j=1 to itemexists(i)
if itemactive(i,j) = 1
ink textcolor,0
text position-text width(menu$(i)),j*20,item$(i,j)
endif
if itemactive(i,j) = 0
ink rgb(175,175,175),0
text position-text width(menu$(i)),j*20,item$(i,j)
endif
if itemchecked(i,j) = 1
paste image 31112,position-text width(menu$(i))+x-15,y+(j*20)+3,1
endif
next j
endif
next i
endfunction
function create_menu(name$)
menuexists = menuexists + 1
menu$(menuexists) = name$
endfunction
function create_menu_item(menu$,itemname$)
for i=1 to menuexists
if menu$(i) = menu$
j = itemexists(i) + 1
itemexists(i) = j
item$(i,j) = itemname$
itemactive(i,j) = 1
itemchecked(i,j) = 0
endif
next i
endfunction
function mouse_click_menu()
`move off submenu to close submenu
totalwidth = 0
for i = 1 to menuexists
position = totalwidth + 20
if menuopen(i) = 1
if mousey() < 18
if mousex() > position + text width(menu$(i)) + 4 or mousex() < position - 4 then menuopen(i) = 0
endif
if mousey() > 18
if mousex() > position + 100 + 20 or mousex() < position - 20 or mousey() > itemexists(i) * 20 + 16 then menuopen(i) = 0
endif
endif
inc totalwidth, 20 + text width(menu$(i))
next i
returnval$ = "not active"
`highlite menu names when over
if menuactive = 1
if mousey() < 15
position = 0
for i = 1 to menuexists
position = position + text width(menu$(i))+20
if mousex() > position-text width(menu$(i))-5 and mousex() < position+5
ink rgb(255,255,255),0
line position-text width(menu$(i))-5,1,position-text width(menu$(i))-5,17
line position-text width(menu$(i))-5,1,position+5,1
ink rgb(100,100,100),0
line position-text width(menu$(i))-5,17,position+5,17
line position+5,1,position+5,17
endif
next i
endif
`click on menu to open submenu
position = 0
if mouseclick() = 1
if mousey() < 15
for i = 1 to menuexists
position = position + text width(menu$(i))+20
menuopen(i) = 0
if mousex() > position-text width(menu$(i))-5 and mousex() < position+5
menuopen(i) = 1
endif
next i
endif
endif
position = 0
for i = 1 to menuexists
position = position + text width(menu$(i))+20
if menuopen(i) = 1
for j = 1 to itemexists(i)
if mousey() > j * 20 and mousey() < j * 20 + 15
ink RGB(64,0,128), 0
box position-text width(menu$(i))-19,j*20,position+100+20-text width(menu$(i)),j*20+15
if itemactive(i,j) = 1 then ink rgb(255,255,255),0 else ink rgb(150,150,150),0
text position-text width(menu$(i)),j*20,item$(i,j)
if mouseclick() = 1 and itemactive(i,j) = 1 then returnval$ = item$(i,j) else returnval$ = "not active"
if itemchecked(i,j) = 1
paste image 31111,position-text width(menu$(i))+x-15,y+(j*20)+3,0
endif
endif
next j
endif
next i
endif
endfunction returnval$
function message_box(text1$,text2$,text3$)
sizex=200
sizey=100
positionx = screen width() / 2 - sizex / 2
positiony = screen height() / 2 - sizey / 2
ink menucolor,0
box positionx, positiony, positionx + sizex , positiony + sizey
ink rgb(255,255,255), 0
line_box(positionx, positiony, positionx + sizex , positiony + sizey)
ink textcolor,0
center text positionx + sizex / 2, positiony, text1$
center text positionx + sizex / 2, positiony + 25, text2$
center text positionx + sizex / 2, positiony + 50, text3$
ink rgb(255,0,0),0
center text positionx + sizex / 2, positiony + 75, "Press space bar"
if scancode() = 57
messageboxexists = 0
endif
endfunction
function line_box(x,y,x1,y1)
line x,y,x,y1
line x1,y,x1,y1
line x,y,x1,y
line x,y1,x1,y1
endfunction
` Utility function to build the checkmark as an image - done through memblocks.
function build_image(imagenumber)
if imagenumber = 31111 then restore w_check_bmp_data
if imagenumber = 31112 then restore b_check_bmp_data
read byte_count
if memblock exist(99) then delete memblock 99
make memblock 99,byte_count
for i = 0 to byte_count-1
read bval
write memblock byte 99,i,bval
next i
make image from memblock imagenumber,99
delete memblock 99
endfunction
w_check_bmp_data:
Rem : First value is the size of the memblock/image format.
Rem : I created this data in 32 bit mode - 32 bit images seem to scale down fine to 16 bit runtime images.
data 268
data 8, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255
data 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255
data 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
b_check_bmp_data:
data 268
data 8, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 2, 2, 2, 255, 2, 2, 2, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 2, 2, 2, 255, 2, 2, 2, 255, 0, 0, 0, 0, 2, 2, 2, 255
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 255
data 2, 2, 2, 255, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 255
data 2, 2, 2, 255, 0, 0, 0, 0, 2, 2, 2, 255, 2, 2, 2, 255
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 2, 2, 2, 255, 2, 2, 2, 255, 2, 2, 2, 255, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 2, 2, 2, 255, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
data 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
here are buttons
global numberofbuttons
numberofbuttons = 10
type buttontype
x1
y1
x2
y2
pic
mouseover
endtype
dim button(numberofbuttons) as buttontype
box 0,0,40,40
get image 1,0,0,40,40,1
ink 0,0
box 10,10,30,30
get image 2,0,0,40,40,1
ink rgb(255,255,255),0
set text size 48
define_buttons()
do
cls 0
draw_buttons()
if mouseclick() = 1
for i = 1 to numberofbuttons
if check_buttons(i) = 1 then print "button ",i," pressed"
if check_buttons(1) = 1 then ink rgb(rnd(255),rnd(255),rnd(255)),0
if check_buttons(2) = 1 then define_buttons()
next i
endif
loop
function define_buttons()
for i = 1 to numberofbuttons
button(i).x1 = rnd(600)
button(i).y1 = rnd(400)
button(i).x2 = button(i).x1+40
button(i).y2 = button(i).y1+40
button(i).pic = 1
button(i).mouseover = 2
next i
endfunction
function draw_buttons()
for i = 1 to numberofbuttons
paste image button(i).pic,button(i).x1,button(i).y1
if check_buttons(i) = 1 then paste image button(i).mouseover,button(i).x1,button(i).y1
next i
endfunction
function check_buttons(bn)
returnval = 0
if mousex() > button(bn).x1 and mousex() < button(bn).x2
if mousey() > button(bn).y1 and mousey() < button(bn).y2
returnval = 1
endif
endif
endfunction returnval
they handle images for the buttons and mouse over images