Problems adding Panel Gadget Item

Just starting out? Need help? Post your questions and find answers here.
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Problems adding Panel Gadget Item

Post by cecilcheah »

Hi there

Can anyone tell me what is wrong with this code:

Code: Select all

PanelGadget(1000, 0, 170, 600, 270)
    For c = 1 To ObjNumber     
      ; do something      
      AddGadgetItem(1000, -1, c)
      
      CloseGadgetList()
    Next
It always tells me I need to Open the gadget before i can close it. But is it not already open?

Cecil
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Once you create all your Tabs in a Panel, then you close it :)

Code: Select all


PanelGadget(1000, 0, 170, 600, 270)
    For c = 1 To ObjNumber          
      AddGadgetItem(1000, -1, c)     
    Next 
CloseGadgetList()
Image Image
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

That works, but another problem arises.

I want to add individual objects in each panel at the same time as the Tab in each panel are being added, with each Object its own #Gadget Number.

Code: Select all

PanelGadget(1000, 0, 170, 600, 270)
    For c = 1 To ObjNumber     
       AddGadgetItem(1000, -1, "Object" + c)
      TextGadget(#Text_2 + (c), 8, 13, 50, 15, "Position")
      SetGadgetFont(#Text_2 + (c), FontID6)
      TextGadget(#Text_3 + (c), 68, 13, 10, 15, "X")
      SetGadgetFont(#Text_3 + (c), FontID6)
      StringGadget(#PosX_ + (c), 83, 13, 65, 20, "")
      SetGadgetFont(#PosX_ + (c), FontID4)
      SetGadgetText(#PosX_ + (c), Str(XPos) )
   Next
CloseGadgetList()

It seems only #Text_2+ (c) is added to each tab. Rest of the objects are only added to the last tab. What have i done wrong?

Cecil
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Most likely you are duplicating gadget numbers. No way of knowing without seeing more of your code ;)

If you create a gadget then use the same gadget number for another gadget, the previous gadget is destroyed.

This shows that the code will work if numbers are not duplicated...

Code: Select all

#Text_2=10
#Text_3=20
#PosX_=30

ObjNumber=3

If OpenWindow(0,0,0,600,480,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
  If CreateGadgetList(WindowID(0))

    PanelGadget(1000, 0, 170, 600, 270)
      For c = 1 To ObjNumber     
        AddGadgetItem(1000, -1, "Object" + Str(c))
        TextGadget(#Text_2 + c, 8, 13, 60, 15, "Position")
        SetGadgetFont(#Text_2 + c, FontID6)
        TextGadget(#Text_3 + c, 68, 13, 10, 15, "X")
        SetGadgetFont(#Text_3 + c, FontID6)
        StringGadget(#PosX_ + c, 83, 13, 65, 20, "")
        SetGadgetFont(#PosX_ + c, FontID4)
        SetGadgetText(#PosX_ + c, Str(XPos) )
      Next
    CloseGadgetList()
    
  EndIf
  
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
If you are new to PureBasic it is best to spend some time going thought the help file and examples folder.
Image Image
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Your code is exactly what i have tried . Once the first object is added to all the tabs, the rest of the objects are only added to the last tab. In your case, it works, in my case not...

Here is my code

Code: Select all


Structure ToolbookObj
  Obj.s
EndStructure

Structure Toolbook_ObjectProp Extends ToolbookObj
  XPos.l
  YPos.l
  Breit.l
  Hohe.l
  FillColor.s
  TextColor.s
  Txt.s
  BorderStyle.s
  ScriftArt.s
  SchriftGross.l
  SchriftStil.s
  TBKObjekt.s
  TBKObjektID.l
  TBKTextAlign.s
  TBKLayer.l
  HTMLStyle.s
  HTMLObj.s
 EndStructure
 
Dim TBK.Toolbook_ObjectProp(100)

 If OpenWindow(20, 282, 124, 600, 452,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "HTML Transfer")
    If CreateGadgetList(WindowID())
      TextGadget(0, 10, 10, 150, 20, "HTML Transfer")
      SetGadgetFont(0, FontID3)
      TextGadget(1, 10, 40, 100, 20, "Transferring...")
      SetGadgetFont(1, FontID4)
      ListViewGadget(10, 0, 60, 600, 50)
      SetGadgetFont(10, FontID5)
      AddGadgetItem(10, -1, "Initialising HTML Transfer...")
      SetGadgetState(10, CountGadgetItems(10)-1)
      
      Delay(150)
      AddGadgetItem(10, -1, "Reading data from Toolbook...")
      SetGadgetState(10, CountGadgetItems(10)-1)

      If ReadFile(1,"temp.txt") 
      While Eof(1)=0  
        If Parameter$                
          Parameter$ = Parameter$ + Chr(13) + ReadString()  ; "
        Else
          Parameter$ = ReadString()
        EndIf
      Wend                                ; " 
        CloseFile(1) 
      Else 
        MessageRequester("HTML Transfer","Error in reading file",0) 
      EndIf 

 
    ObjNumber = CountString(Parameter$, "|") + 1
    AddGadgetItem(10, -1, "Start to transfer Toolbook Objects...")
    SetGadgetState(10, CountGadgetItems(10)-1)
    
    For c = 1 To ObjNumber     

      TBK(c)\Obj  = StringField(Parameter$,c,"|")
      TBK(c)\XPos  = Val(StringField(TBK(c)\Obj,1,"§"))
      TBK(c)\YPos  = Val(StringField(TBK(c)\Obj,2,"§"))
      TBK(c)\Breit  = Val(StringField(TBK(c)\Obj,3,"§"))
      TBK(c)\Hohe  = Val(StringField(TBK(c)\Obj,4,"§"))
      TBK(c)\FillColor  = "#" + Hex1(Val(StringField(StringField(TBK(c)\Obj,5,"§"),1,","))) + Hex1(Val(StringField(StringField(TBK(c)\Obj,5,"§"),2,","))) + Hex1(Val(StringField(StringField(TBK(c)\Obj,5,"§"),3,",")))
      TBK(c)\TextColor  = "#" + Hex1(Val(StringField(StringField(TBK(c)\Obj,6,"§"),1,","))) + Hex1(Val(StringField(StringField(TBK(c)\Obj,6,"§"),2,","))) + Hex1(Val(StringField(StringField(TBK(c)\Obj,6,"§"),3,",")))
      TBK(c)\Txt  = ReplaceString(StringField(TBK(c)\Obj,7,"§"),Chr(13),"<br/>")
      TBK(c)\BorderStyle  = StringField(TBK(c)\Obj,8,"§")
      TBK(c)\ScriftArt  = StringField(TBK(c)\Obj,9,"§")
      TBK(c)\SchriftGross  = Val(StringField(TBK(c)\Obj,10,"§"))
      TBK(c)\SchriftStil  = StringField(TBK(c)\Obj,11,"§")
      If TBK(c)\SchriftStil = "bold"
        TBK(c)\SchriftStil = "font-weight: bold;"
      Else
        If TBK(c)\SchriftStil = "italic"
          TBK(c)\SchriftStil = "font-style: italic;"
        Else
          If TBK(c)\SchriftStil = "bold,italic"
            TBK(c)\SchriftStil  = "font-style: italic; font-weight: bold;"
          Else
            TBK(c)\SchriftStil  = "font-style: normal;"
          EndIf
        EndIf
      EndIf
      TBK(c)\TBKObjekt  = StringField(TBK(c)\Obj,12,"§")
      TBK(c)\TBKObjektID  = Val(StringField(TBK(c)\Obj,13,"§"))
      
      
      
      AddGadgetItem(10, -1, "Transfering " + TBK(c)\TBKObjekt + " ID Number " + Str(TBK(c)\TBKObjektID) + " ...")
      SetGadgetState(10, CountGadgetItems(10)-1)
       
      TBK(c)\TBKTextAlign  = StringField(TBK(c)\Obj,14,"§")
      TBK(c)\TBKLayer = Val(StringField(TBK(c)\Obj,15,"§"))
      TBK(c)\HTMLStyle = ".Style" + StrU(c,#Long) + " { position: absolute; left: " + Str(TBK(c)\XPos) + "px; top: " + Str(TBK(c)\YPos) + "px; height: " + Str(TBK(c)\Hohe) + "px; width: " + Str(TBK(c)\Breit) + "px; text-align :" + TBK(c)\TBKTextAlign + "; font-family: " + TBK(c)\ScriftArt  + "; font-size: " + StrU(TBK(c)\SchriftGross,#Long) + "pt; " + TBK(c)\SchriftStil + " color: " + TBK(c)\TextColor + "; z-index: " + Str(TBK(c)\TBKLayer) + ";"
      If TBK(c)\TBKObjekt = "Field"
      ;  MessageRequester("HTML Transfer", TBK(c)\BorderStyle , #PB_MessageRequester_Ok) 
        Select TBK(c)\BorderStyle
        Case "rectangle"
          TBK(c)\HTMLStyle = TBK(c)\HTMLStyle + " border-style: solid; border-width: thin;}"
        Default
          TBK(c)\HTMLStyle = TBK(c)\HTMLStyle + "}"
        EndSelect
      Else
        TBK(c)\HTMLStyle = TBK(c)\HTMLStyle + "}"
      EndIf
      If TBK(c)\TBKObjekt = "Button"
;        TBK(c)\HTMLObj = "<Input class = " + Chr(34) + "Style" + StrU(c,#Long) + Chr(34) + " type = "  + Chr(34) + "Submit" + Chr(34) + " name = " + Chr(34) + TBK(c)\Txt  + Chr(34) + " value = "  + Chr(34) + TBK(c)\Txt + Chr(34) + ">"
        TBK(c)\HTMLObj = "<Button class = " + Chr(34) + "Style" + StrU(c,#Long) + Chr(34) + " type = "  + Chr(34) + "Button" + Chr(34) + " name = " + Chr(34) + TBK(c)\Txt  + Chr(34) + " value = "  + Chr(34) + TBK(c)\Txt + Chr(34) + ">" + TBK(c)\Txt + "</button>"
      Else
        If TBK(c)\TBKObjekt = "Field" And TBK(c)\BorderStyle = "inset"
          TBK(c)\HTMLObj = "<Input class = " + Chr(34) + "Style" + StrU(c,#Long) + Chr(34) + " type = "  + Chr(34) + "text" + Chr(34) + " name = " + Chr(34) + "textField" + Str(c)  + Chr(34) + " value = "  + Chr(34) + TBK(c)\Txt + Chr(34) + " size = " + Chr(34) + Str(TBK(c)\Breit) + Chr(34) + "/>"
         ; TBK(c)\HTMLObj = "<Div class = " + Chr(34) + "Style" + StrU(c,#Long) + Chr(34) + "</div>" + TBK(c)\Txt + "</div>"
        Else
          TBK(c)\HTMLObj = "<Div class = " + Chr(34) + "Style" + StrU(c,#Long) + Chr(34) + "</div>" + TBK(c)\Txt + "</div>"
        EndIf
      EndIf
    Next
    
    
    PanelGadget(1000, 0, 170, 600, 270) 
      For c = 1 To ObjNumber      
        AddGadgetItem(1000, -1, "Object" + Str(c)) 
        TextGadget(#Text_2 + c, 8, 13, 60, 15, "Position") 
        SetGadgetFont(#Text_2 + c, FontID6) 
        TextGadget(#Text_3 + c, 68, 13, 10, 15, "X") 
        SetGadgetFont(#Text_3 + c, FontID6) 
        StringGadget(#PosX_ + c, 83, 13, 65, 20, "") 
        SetGadgetFont(#PosX_ + c, FontID4) 
        SetGadgetText(#PosX_ + c, Str(XPos) ) 
      Next 
    CloseGadgetList() 
  Delay(1) 
  
 
  EndIf

  AddGadgetItem(10, -1, "Writing HTML File...")
  SetGadgetState(10, CountGadgetItems(10)-1)
 ; (more code follows)
Help file and searching the Forum has no help, i have tried it.

Try and run your Code and you will see what i mean.

Cecil[/quote]
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Actually try your code but increase the ObjectNumber to 23, and you will see my problem.

Code: Select all

#Text_2=10 
#Text_3=20 
#PosX_=30 

ObjNumber=23 

If OpenWindow(0,0,0,600,480,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"") 
  If CreateGadgetList(WindowID(0)) 

    PanelGadget(1000, 0, 170, 600, 270) 
      For c = 1 To ObjNumber      
        AddGadgetItem(1000, -1, "Object" + Str(c)) 
        TextGadget(#Text_2 + c, 8, 13, 60, 15, "Position") 
        SetGadgetFont(#Text_2 + c, FontID6) 
        TextGadget(#Text_3 + c, 68, 13, 10, 15, "X") 
        SetGadgetFont(#Text_3 + c, FontID6) 
        StringGadget(#PosX_ + c, 83, 13, 65, 20, "") 
        SetGadgetFont(#PosX_ + c, FontID4) 
        SetGadgetText(#PosX_ + c, Str(XPos) ) 
      Next 
    CloseGadgetList() 
    
  EndIf 
  
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 
Cecil
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

if you increase 'ObjectNumber' above 10 you'll start overwriting gadget numbers again! if you increase the nr of objects you need to change the offset also!
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

What offset are we talking about? Can you give me an example code.

Thanks
Cecil
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

cecilcheah wrote:What offset are we talking about? Can you give me an example code.
It's in the code already posted in this thread!
Particulary look after the following constants in the source code, as they are used as offset when creating the gadgets:

Code: Select all

#Text_2=10
#Text_3=20
#PosX_=30 
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Here's another example trying to show you the offset thing...

Code: Select all

#Gadget=0  ;we will start our gadget count at 0

#offset=3   ;each tab has 3 gadgets so the offset is 3
ObjNumber=10 * #offset   ;in this example we want 10 tabs

If OpenWindow(0,0,0,600,480,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
  If CreateGadgetList(WindowID(0))

    PanelGadget(1000, 0, 170, 600, 270)
      For c = 1 To ObjNumber Step #offset    
        AddGadgetItem(1000, -1, "Object" + Str(c/#offset))
        TextGadget(#Gadget+c, 8, 13, 60, 15, "Position")  ;1st gadget in tab
        SetGadgetFont(#Gadget+c, FontID6)
        TextGadget(#Gadget+1+c, 68, 13, 10, 15, "X")  ;2nd gadget in tab
        SetGadgetFont(#Gadget+1+c, FontID6)
        StringGadget(#Gadget+2+c, 83, 13, 65, 20, "")  ;3rd gadget in tab
        SetGadgetFont(#Gadget+2+c, FontID4)
        SetGadgetText(#Gadget+2+c, Str(XPos) )
      Next
    CloseGadgetList()
   
  EndIf
 
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf 

Like I said... read the help file. Read all of it. It will make your life easier :)
Image Image
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

Hi there

Your code make sense, though i have to change a bit to make my life easier. And now i have found another problem.

Since i do not know how many objects there are beforehand, as this is dynamically generated, when i set the #Gadget object number to > 10000, i am getting an error:
#Gadget object number is very high (over 10000), are You sure of that?
Is there a way to have the Garget Number > 10000

I am sure i did read the help file before i post here, but find no info on this problem.

Cecil
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

By using a gadget number of 10,000 PureBasic reserves space (according to Fred) for 10,000 gadgets. As you can see, it is bad to start your numbers this high if you only have 5 gadgets on your form since there will be lots of waste. (That is why PB gives you a warning)

Why do you not create your form with everything you need, then draw the panel stuff (dynamic stuff) last, starting at the gadget number you left off on. That way you are not wasting gadget numbers.

You could also take a different approach and use #PB_Any, letting PB handle the numbering for you since you seem to be confused how it all works ;)
Of course using this method you will have to keep track of all the ID numbers returned so you can actually use the gadgets... giving you even more work. (better stick with the first method)
Image Image
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

a different approach is using enumeration, define all gadgets with enumeration blocks, and you can't go wrong, unless you dynamically create your gui elements
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
cecilcheah
Enthusiast
Enthusiast
Posts: 168
Joined: Wed Jun 04, 2003 8:44 am
Location: Switzerland

Post by cecilcheah »

To answer both of you, here is my code:

Code: Select all

Enumeration
  #Text_0
  #Text_1
  #Listview_0
  #Button_0
  #Panel_0
  #Gadget = 100
  #PosX_ = 3000
  #PosY_ = 3500
  #Breit_ = 4000
  #Hohe_ = 4500
  #SchriftArt_ = 5000
  #SchriftGross_ = 5500
  #SchriftStil_ = 6000
  #SchriftFarbe_ = 6500
  #Farbe_ = 7000
  #RandStil_ = 7500
  #Texte_ = 8000
  #Sicht_ = 8500
  #Alignment_ = 9000

  #offset=16

EndEnumeration
And the other code:

Code: Select all

For c = #offset To ObjNumber * #offset  Step #offset
      AddGadgetItem(#Panel_0, -1, TBK(c/#offset)\TBKObjekt + " ID Number " + Str(TBK(c/#offset)\TBKObjektID))
      TextGadget(#Gadget + c, 8, 13, 50, 15, "Position")
      SetGadgetFont(#Gadget + c, FontID6)
      TextGadget(#Gadget+1 + c, 68, 13, 10, 15, "X")
      SetGadgetFont(#Gadget+1 + c, FontID6)
      StringGadget(#PosX_ + c/#offset, 83, 13, 65, 20, "")
      SetGadgetFont(#PosX_ + c/#offset, FontID4)
      SetGadgetText(#PosX_ + c/#offset,Str(TBK(c/#offset)\XPos))
      TextGadget(#Gadget+2 + c, 158, 13, 15, 15, "Y")
      SetGadgetFont(#Gadget+2 + c, FontID6)
      StringGadget(#PosY_ + c/#offset, 178, 13, 65, 20, "")
      SetGadgetFont(#PosY_ + c/#offset, FontID4)
      SetGadgetText(#PosY_ + c/#offset,Str(TBK(c/#offset)\YPos))
      TextGadget(#Gadget+3 + c, 263, 13, 35, 20, "Size")
      SetGadgetFont(#Gadget+3 + c, FontID6)
      TextGadget(#Gadget+4 + c, 303, 13, 40, 15, "Width")
      SetGadgetFont(#Gadget+4 + c, FontID6)
      StringGadget(#Breit_ + c/#offset, 348, 13, 45, 20, "")
      SetGadgetFont(#Breit_ + c/#offset, FontID4)
      SetGadgetText(#Breit_  + c/#offset,Str(TBK(c/#offset)\Breit))
      TextGadget(#Gadget+5 + c, 398, 13, 40, 15, "Height")
      SetGadgetFont(#Gadget+5 + c, FontID6)
      StringGadget(#Hohe_ + c/#offset, 453, 13, 45, 20, "")
      SetGadgetFont(#Hohe_ + c/#offset, FontID4)
      SetGadgetText(#Hohe_  + c/#offset,Str(TBK(c/#offset)\Hohe))
      TextGadget(#Gadget+6 + c, 8, 38, 35, 20, "Font")
      SetGadgetFont(#Gadget+6 + c, FontID6)
      TextGadget(#Gadget+7 + c, 58, 38, 35, 15, "Name")
      SetGadgetFont(#Gadget+7 + c, FontID6)
      TextGadget(#Gadget+8 + c, 213, 38, 30, 15, "Size")
      SetGadgetFont(#Gadget+8 + c, FontID6)
      TextGadget(#Gadget+9 + c, 308, 38, 30, 15, "Style")
      SetGadgetFont(#Gadget+9 + c, FontID6)
      StringGadget(#SchriftArt_ + c/#offset, 98, 38, 105, 20, "")
      SetGadgetFont(#SchriftArt_ + c/#offset, FontID4)
      SetGadgetText(#SchriftArt_  + c/#offset,TBK(c/#offset)\ScriftArt)
      StringGadget(#SchriftGross_ + c/#offset, 248, 38, 50, 20, "")
      SetGadgetFont(#SchriftGross_ + c/#offset, FontID4)
      SetGadgetText(#SchriftGross_  + c/#offset,Str(TBK(c/#offset)\SchriftGross))
      StringGadget(#SchriftStil_ + c/#offset, 353, 38, 85, 20, "")
      SetGadgetFont(#SchriftStil_ + c/#offset, FontID4)
      SetGadgetText(#SchriftStil_  + c/#offset,TBK(c/#offset)\SchriftStil)
      TextGadget(#Gadget+10 + c, 153, 63, 40, 15, "Stroke")
      SetGadgetFont(#Gadget+10 + c, FontID6)
      StringGadget(#SchriftFarbe_ + c/#offset, 198, 63, 70, 20, "")
      SetGadgetFont(#SchriftFarbe_ + c/#offset, FontID4)
      SetGadgetText(#SchriftFarbe_  + c/#offset,TBK(c/#offset)\TextColor)
      
      TextGadget(#Gadget+11 + c, 8, 63, 40, 15, "Color")
      SetGadgetFont(#Gadget+11 + c, FontID6)
      StringGadget(#Farbe_ + c/#offset, 78, 63, 65, 20, "")
      SetGadgetFont(#Farbe_ + c/#offset, FontID4)
      SetGadgetText(#Farbe_ + c/#offset,TBK(c/#offset)\FillColor)
      
      TextGadget(#Gadget+12 + c, 58, 63, 20, 15, "Fill")
      SetGadgetFont(#Gadget+12 + c, FontID6)
      TextGadget(#Gadget+13 + c, 278, 63, 80, 15, "Border Style")
      SetGadgetFont(#Gadget+13 + c, FontID6)
      StringGadget(#RandStil_ + c/#offset, 363, 63, 80, 20, "")
      SetGadgetFont(#RandStil_ + c/#offset, FontID4)
      SetGadgetText(#RandStil_ + c/#offset,TBK(c/#offset)\BorderStyle)
      
      TextGadget(#Gadget+14 + c, 8, 93, 35, 15, "Text")
      SetGadgetFont(#Gadget+14 + c, FontID6)
      StringGadget(#Texte_ + c/#offset, 53, 88, 535, 135, "")
      SetGadgetFont(#Texte_ + c/#offset, FontID4)
      SetGadgetText(#Texte_ + c/#offset,TBK(c/#offset)\Txt)
      
      TextGadget(#Gadget+15 + c, 453, 38, 40, 15, "Layer")
      SetGadgetFont(#Gadget+15 + c, FontID6)
      TextGadget(#Gadget+16 + c, 453, 63, 35, 20, "Align")
      SetGadgetFont(#Gadget+16 + c, FontID6)
      StringGadget(#Sicht_ + c/#offset, 498, 38, 40, 20, "")
      SetGadgetFont(#Sicht_ + c/#offset, FontID4)
      SetGadgetText(#Sicht_ + c/#offset,Str(TBK(c/#offset)\TBKLayer))
      
      StringGadget(#Alignment_ + c/#offset, 498, 63, 80, 20, "")
      SetGadgetFont(#Alignment_ + c/#offset, FontID4)
      SetGadgetText(#Alignment_ + c/#offset,TBK(c/#offset)\TBKTextAlign)
      
      Next 
    CloseGadgetList()
In this code, i do not know how many tabs there are, but each tab will have 16 Gadget Objects as well as 14 different String Gadgets. I need to retireve the text value of the String Gadget, so i have to do it this way.

Now, as i say, i do not know how many Tabs or Object Numbers there will be. I start with 100 and goes up to 3000. This gives me 2900 numbers i can use. each tab will contain at the moment 16 Gadget objects, that will mean i can only create dynamically 181 Tabs. Thus is not enough for me. I need at least 500 Tabs to start with and each object may have up to 50 Gadget Objects in each Tab. I am talking well over 100,000 at least. Is this possible? If not, what can i do to go around this?

Cecil
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1286
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

You are creating an app with over 10,000 gadgets ?!?!? 8O

LOL !!!

I hope this is just for personal use cause I can't imagine a poor user having to scroll through 500 tabs on a panel just to find what he needs.


Anyway, you are still not understanding the offset thing. Using the example I posted you can have 500 and more tabs all containing gadgets.... see:

Code: Select all

#Panel=0
#Gadget=1  ;we will start our gadget count at 0

#offset=3   ;each tab has 3 gadgets so the offset is 3
ObjNumber=500 * #offset   ;in this example we want 10 tabs

If OpenWindow(0,0,0,600,480,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"")
  If CreateGadgetList(WindowID(0))

    PanelGadget(#Panel, 0, 170, 600, 270)
      For c = 1 To ObjNumber Step #offset   
        AddGadgetItem(0, -1, "Object" + Str(c/#offset))
        TextGadget(#Gadget+c, 8, 13, 60, 15, "Position")  ;1st gadget in tab
        SetGadgetFont(#Gadget+c, FontID6)
        TextGadget(#Gadget+1+c, 68, 13, 10, 15, "X")  ;2nd gadget in tab
        SetGadgetFont(#Gadget+1+c, FontID6)
        StringGadget(#Gadget+2+c, 83, 13, 65, 20, "")  ;3rd gadget in tab
        SetGadgetFont(#Gadget+2+c, FontID4)
        SetGadgetText(#Gadget+2+c, Str(#Gadget+2+c) )
      Next
    CloseGadgetList()
   
  EndIf

  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf

Regardless, doesn't Windows itself have a limit to the number of handles an app is allowed to have? (meaning there would be a limit to the number of gadgets an app could use)


:wink:
Image Image
Post Reply