BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"Simple GUI Button Interface"
, by steve-ancell
Allows the activation of functions or commands at the click of a mouse
Code
;Simple GUI Buttons Example ;Written in Blitz Basic 2D ;By Stephen Ancell ;February / 23 / 2003 AppTitle"GUI Buttons Example" Global gw=800,gh=600,gd=16,gm=2 Graphics gw,gh,gd,gm Type button Field x,y Field w,h Field func$ End Type create_button(0,100,50,25,"a") create_button(60,100,50,25,"b") create_button(120,100,50,25,"c") disp_button() Repeat detect_button() Until KeyHit(1) End Function create_button(x,y,w,h,func$) b.button=New button b\x=x b\y=y b\w=w b\h=h b\func$=func$ End Function Function disp_button() Cls Color 255,255,255 Text 0,0,"click on one of the boxes" Text 0,16,"press [Esc] to exit example" For b.button=Each button Color 0,100,150 Rect b\x,b\y,b\w,b\h,1 Next End Function Function detect_button() If Not MouseHit(1) Return EndIf disp_button() For b.button=Each button If MouseX()>b\x If MouseX()<(b\x+b\w) If MouseY()>b\y If MouseY()<(b\y+b\h) exec_func(b\func$) EndIf EndIf EndIf EndIf Next End Function Function exec_func(func$) Color 255,255,255 Select func$ Case "a" Text (gw/2),(gh/2),"button a" Case "b" Text (gw/2),(gh/2),"button b" Case "c" Text (gw/2),(gh/2),"button c" End Select End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations