_Title "Get Button Menu" 'bplus 2021-03-11 ' B+ 2021-03-11 Rewrite 191Brian list picker https://www.qb64.org/forum/index.php?topic=3730.msg130862#msg130862
' assuming default font 8x16
'Globals here, Cap first letters
_Delay .25 'give screen time to load before
'locals for main event code, keep locals lowercase on first letter
ReDim monthNames$
, monthPick$
, years$
, yearPick$
, days$
, dayPick$
ReDim months$
(1 To 1) '<<<<<<<<<<<< don't need to know in advance the number of items in split sting but good to start at 1 For i
= 1 To 31 'create days and years strings If i
= 1 Then years$
= TS$
(2000 + i
) Else years$
= years$
+ "," + TS$
(2000 + i
) If i
= 1 Then days$
= TS$
(i
) Else days$
= days$
+ "," + TS$
(i
) monthNames$ = "January,February,March,April,May,June,July,August,September,October,November,December"
MakeButtons &HFFFF8888, &HFF880000, 300, 0, years$, yearButtons()
MakeButtons
&HFF88FF88, &HFF008800, 369, (_Height - 12 * 25) / 2, monthNames$
, monthButtons
()MakeButtons &HFF8888FF, &HFF0000FF, 478, 0, days$, dayButtons()
nMonths
= UBound(monthButtons
)
''check the making all good!
'For i = 1 To nMonths
' Print MonthButtons(i).x, MonthButtons(i).y, MonthButtons(i).w, MonthButtons(i).h, MonthButtons(i).text
'Next
'End
Print "Last Date Picked: " + yearPick$
+ "-" + monthPick$
+ "-" + dayPick$
DrawButton yearButtons(i)
DrawButton monthButtons(i)
DrawButton dayButtons(i)
If InBoxTF&
(mx
, my
, yearButtons
(i
)) Then yearPick$
= yearButtons
(i
).text:
GoTo continue
If InBoxTF&
(mx
, my
, monthButtons
(i
)) Then monthPick$
= monthButtons
(i
).text:
GoTo continue
If InBoxTF&
(mx
, my
, dayButtons
(i
)) Then dayPick$
= dayButtons
(i
).text:
GoTo continue
continue:
curpos
= 1: arrpos
= LBound(loadMeArray
): LD
= Len(delim
) dpos
= InStr(curpos
, SplitMeString
, delim
) loadMeArray
(arrpos
) = Mid$(SplitMeString
, curpos
, dpos
- curpos
) arrpos = arrpos + 1
curpos = dpos + LD
dpos
= InStr(curpos
, SplitMeString
, delim
) loadMeArray
(arrpos
) = Mid$(SplitMeString
, curpos
)
If y
>= b.y
And y
<= b.y
+ b.h
Then InBoxTF&
= -1
Sub DrawButton
(b
As Button
) Line (b.x
, b.y
)-Step(b.w
, b.h
), b.BC
, BF
_PrintString ((b.x
+ (b.w
- 8 * Len(b.text
)) / 2), b.y
+ (b.h
- 16) / 2), b.text
Split CommaDelimitedList$
, ",", list$
()
'what's longest item?
ReDim arr
(1 To items
) As Button
' make month buttons arr(i).x = X
arr(i).y = Y + 20 * (i - 1)
arr(i).w = 8 * (lngItem + 4)
arr(i).h = 18 'assuming default font
arr(i).FC = fore
arr(i).BC = back