Creating gadgets Realtime?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Can I create gadgets Realtime? (on the fly).

e.g. from reading an ini file.

Or must I predefine a couple of gadgets and then hide/show, activate etc.

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Can I create gadgets Realtime? (on the fly).
> e.g. from reading an ini file.

Sure... creating 10 gadgets at startup is just the same as creating
5 at startup and another 5 later on in your code.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.

In Paul's site you can find some example using an ini file (ini2GUI is the name of the example).

Here is another example:

Code: Select all

If OpenWindow(0,100,10,250,500,#PB_Window_SystemMenu,"Create Gadgets at Runtime!")
  CreateGadgetList(WindowID())
  ButtonGadget(0,1,1,90,25,"Create Button")
  Repeat
    EventID=WaitWindowEvent()
    
    Select EventID
    
      Case #PB_EventGadget
        Select EventGadgetID()
          Case 0
            GadgetNum  = GadgetNum + 1
            ButtonGadget(GadgetNum,1 ,30*GadgetNum,80,25, "Button #" +Str(GadgetNum))
          Default
            MessageRequester("Click","Button#" + Str(EventGadgetID())+" was clicked",0)
        EndSelect
    
    EndSelect
    
  Until EventID=#PB_EventCloseWindow
EndIf
Post Reply