Here's a Quick Menu or Button set Demo: in less than <40 LOC for 2 procedures with <20 LOC demo
Meant to be modified to needs of application.
Code: (Select All)
Option _Explicit
Dim Shared xmax, ymax
xmax = 800: ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 200, 60
Dim Menu$(5), selectNumber%
Menu$(0) = "1st Choice"
Menu$(1) = "2nd Choice"
Menu$(2) = "3rd Choice"
Menu$(3) = "4th Choice"
Menu$(4) = "5th Choice"
Menu$(5) = "Quit"
Do
Color &HFFFFFFFF, &HFF000000: Cls
selectNumber% = getButtonNumberChoice%(Menu$())
Print "You selected: "; Menu$(selectNumber%); " zzz..."
Sleep
If selectNumber% = 5 Then End
Loop
'this works pretty good for a menu of buttons to get menu number
Function getButtonNumberChoice% (choice$())
Dim As Long ub, b, mx, my, mb
'this sub uses drwBtn
ub = UBound(choice$)
For b = 0 To ub ' drawing a column of buttons at xmax - 210 starting at y = 10
drwBtn xmax - 210, b * 60 + 10, choice$(b)
Next
Do
While _MouseInput: Wend
mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
If mb Then
If mx > xmax - 210 And mx <= xmax - 10 Then
For b = 0 To ub
If my >= b * 60 + 10 And my <= b * 60 + 60 Then
Line (xmax - 210, 0)-(xmax, ymax), , BF
getButtonNumberChoice% = b: Exit Function
End If
Next
Beep
Else
Beep
End If
_Delay .1
End If
_Limit 60
Loop
End Function
Sub drwBtn (x, y, s$) '200 x 50
Line (x, y)-Step(200, 50), _RGB32(0, 0, 0), BF
Line (x, y)-Step(197, 47), _RGB32(255, 255, 255), BF
Line (x + 1, y + 1)-Step(197, 47), &HFFBABABA, BF
Color _RGB32(0, 0, 0), &HFFBABABA
_PrintString (x + 100 - 4 * Len(s$), y + 17), s$
End Sub
Meant to be modified to needs of application.
b = b + ...