06-30-2022, 06:51 PM
This went pretty well! Now you make controls from a form in your favorite txt editor, the QB64 code reads the form and writes the NewControl line for your app and you check it over and add it to the Control Stack.txt file if looks OK or send it back to editor (or quit).
Code: (Select All)
_Title "Make New Controls with Properties" ' b+ 2022-06-30
' oh put in defaults if things are left blank, eh do it with NewControl Function need to know conType.
Input "Clear the Controls Stack.txt file (for fresh start)? Enter y/n "; answer$
If LCase$(answer$) = "y" Then
Open "Controls Stack.txt" For Output As #1
Close #1
End If
Do
Input "Enter 'e' to Edit last control saved, enter 'a' for A new control blank, enter 'q' to Quit "; answer$
If LCase$(answer$) = "e" Then
GoTo edit
ElseIf answer$ = "a" Then
GoTo again
Else
End
End If
again: ' fresh form
Open "Control Properties Form.txt" For Output As #1
Print #1, " Edit your New Control Properties as needed:"
Print #1, ""
Print #1, " Tip: Run the 3 Digit Color Picker with the txt Editor."
Print #1, ""
Print #1, " Control Name / Handle = "
Print #1, "Control type 1:Btn, 2:TB, 3:Lst, 4:Lbl, 5:Pic conType = "
Print #1, " Left side X = "
Print #1, " Top Y = "
Print #1, " Width W = "
Print #1, " Height H = "
Print #1, " Font Height FH = "
Print #1, " 3 Digit Fore Color FC = "
Print #1, " 3 Digit Back Color BC = "
Print #1, " T/F, Yes:-1 or No:0 Tab Stop = -1"
Print #1, " T/F: active/hidden use -1 or 0 Hide = 0"
Print #1, " Text = "
Print #1, " Font .ttf, Data .txt or Image .png File = "
Print #1, ""
Print #1, ""
Print #1, "Fill out the parts right of = sign, Save and Exit you txt Editor."
Print #1, ""
Print #1, "Note:"
Print #1, "All are Long number types except Text and File which are strings, colors are 3 digits Integers for RGB conversion."
Close #1
edit: ' current form
Shell Chr$(34) + "Control Properties Form.txt" + Chr$(34)
' Write a NewControl line and check it
Open "Control Properties Form.txt" For Input As #1
For i = 1 To 5
Line Input #1, fl$
Next
s$ = RightOf$(fl$, "=") + " = NewControl(" ' name/handle
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' contype
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' X
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' Y
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' W
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' H
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' FH
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' FC
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' BC
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' Tab
Line Input #1, fl$
s$ = s$ + RightOf$(fl$, "=") + ", " ' Hide
Line Input #1, fl$
s$ = s$ + Chr$(34) + RightOf$(fl$, "=") + Chr$(34) + ", " ' Text
Line Input #1, fl$
s$ = s$ + Chr$(34) + RightOf$(fl$, "=") + Chr$(34) + ")" ' File
Close #1
Print s$ ' let's see what we have
Input "Add to Controls Stack y/n"; answer$
If LCase$(answer$) = "y" Then
Open "Controls Stack.txt" For Append As #1
Print #1, s$
Close #1
End If
Loop
' update these 2 in case of$ is not found! 2021-02-13 mod with trim$ for this app
Function RightOf$ (source$, of$)
If InStr(source$, of$) > 0 Then RightOf$ = _Trim$(Mid$(source$, InStr(source$, of$) + Len(of$))) Else RightOf$ = ""
End Function
b = b + ...