Gadget arrays?
-
- Enthusiast
- Posts: 429
- Joined: Sun Apr 06, 2008 12:54 pm
- Location: Brisbane, Qld, Australia
- Contact:
Gadget arrays?
Having started with PureBasic in the days before Form Designer was available, I hard-coded my form layouts. But I've decided it's time I had a look at Form Designer, and what I've found so far I like. However, something I need often is to have arrays of gadgets within a ScrollAreaGadget. These typically include a mixture of string gadgets, combobox gadgets and possibly also a button gadget. I know I can set up one row of these in Form Designer, then select them all, then and copy and paste them multiple times. But all these gadgets will have unique names. What I want is to have the generated code create gadget arrays, and a loop that contains just one subscripted instance of each gadget in the row. This is necessary to simplify populating and processing the rows. Is this possible using Form Designer?
Re: Gadget arrays?
I don't know any designer who can create arrays.
But if you use constants (not PB_Any) you can use the tab order.
The FormDesigner can handle this if you change the order of the gadgets in the OpenWindow procedure.
Switch to code view and sort the gadgets. Then switch back to Designer View and save it so that the designer can recreate the enumeration.
[/size]
[/size]
But if you use constants (not PB_Any) you can use the tab order.
The FormDesigner can handle this if you change the order of the gadgets in the OpenWindow procedure.
Switch to code view and sort the gadgets. Then switch back to Designer View and save it so that the designer can recreate the enumeration.
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Enumeration FormWindow
#Window_0
EndEnumeration
Enumeration FormGadget
#Text_0
#Text_1
#Text_2
#String_0
#String_1
#String_2
EndEnumeration
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu)
TextGadget(#Text_0, 10, 10, 80, 30, "")
TextGadget(#Text_1, 10, 50, 80, 30, "")
TextGadget(#Text_2, 10, 90, 80, 20, "")
StringGadget(#String_0, 100, 10, 120, 30, "")
StringGadget(#String_1, 100, 50, 120, 30, "")
StringGadget(#String_2, 100, 90, 120, 30, "")
EndProcedure
Code: Select all
IncludeFile "Form1.pbf"
Global Dim sVal.s(3)
sVal(0) = "String 1"
sVal(1) = "String 2"
sVal(2) = "String 3"
Procedure Main()
Protected i, index
OpenWindow_0()
If WindowID(#Window_0)
For i = #String_0 To #String_2
index = i - #String_0
SetGadgetText(i, sVal(index))
Next
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Enthusiast
- Posts: 429
- Joined: Sun Apr 06, 2008 12:54 pm
- Location: Brisbane, Qld, Australia
- Contact:
Re: Gadget arrays?
Thanks, mk-soft. That's very helpful. Being able to reorder the gadgets in the OpenWindow procedure and having Form Designer accept the new order is definitely a workable solution.