Creating Buttons Creating Buttons Creating a button in a window is a simple matter of placing a graphic representing your button on the screen, and then looking to see if a mouse event occurred within the confines of that graphic. GPANEL Instruction The GPANEL instruction is useful for creating standard button graphics. The syntax for GPANEL is: GPANEL (glun, mode) x, y, dx, dy glun The logical unit of the window the button is in. mode is replaced with:
0 indicating a raised, ungrooved panel 2 indicating a sunken, ungrooved panel 4 indicating a raised, grooved panel 6 indicating a sunken, grooved panel (Adding 1 to any of the mode values fills the panel with foreground color.) x y Coordinates of the upper left corner of the button. dx dy Width and height of the button. Button Example This code segment places a button on the screen and then monitor a button-up event at that button (the logical unit the button is accessing must be ATTACHed and FOPENed):
; Initialize monitoring of button events for a button FSET (glun) "/event button" ; Draw a 45x45 pixel panel at window coordinates 100,100 GPANEL (glun, 0) 100, 100, 45, 45 ; Put a label in the button GTYPE (glun) 102, 122, "Label" ; Declare a variable for pointer event 2 (button up) btn.up = 2 ; Set a variable that will stop the monitoring of button ; events hit = FALSE ; Start a loop waiting for a button-up event DO GETEVENT (glun) event[] eV+Language User's Guide, v2.x, 18318-000 Rev A Page 170