Parent/Child Type Structuring

Blitz3D Forums/Blitz3D Programming/Parent/Child Type Structuring

Hi,

I have used Stevie G's method as its the kind of structure I have been looking to addopt. Below is a little code which contains a Gadget Type and 2 slider types as children. Can anyone show me how to display image the gadget and the sliders in the main program loop using a global reference to the type structure PLAYER1. Thanks,

Graphics 800,600,0,2

SeedRnd MilliSecs()

;----Type declerations----------

Type GADGET
Field GID% ; Gadget ID
Field GIMAGE$ ; Image
Field GX% ; X Pos
Field GY% ; Y Pos
Field GW% ; Gadget Width
Field GH% ; Gadget Height
End Type

Type SLIDER
Field Parent.GADGET ; The sliders parent is the gadget
Field SID% ; Slider ID
Field SIMAGE$ ; Image
Field SX% ; X Pos
Field SY% ; Y Pos
Field SW% ; Slider Width
Field SH% ; Slider Height
Field SMAX% ; Slider Max value
Field SMIN% ; Slider Min value
End Type

;-------------------------------

Global PLAYER1.GADGET = CreateGadget( 0,"mp3player1.bmp",100,100,300,200)
CreateSlider(PLAYER1,0,0,12,67,"slider.bmp",40,10,100,0)
CreateSlider(PLAYER1,0,0,60,67,"slider.bmp",40,10,100,0)

;-------------------------------



SetBuffer BackBuffer()

While Not KeyHit(1)


Flip
Wend

End

;-------------------------------

Function CreateGadget.gadget(GID%,GIMAGE$,GX%,GY%,GW%,GH%) ;Create a Gadget

G.GADGET = New GADGET
G\GID% = GID%
G\GIMAGE = LoadImage(GIMAGE$)
G\GX% = GX%
G\GY% = GY%
G\GW% = GW%
G\GH% = GH%

Return G
End Function

Function CreateSlider(G.GADGET,SID%,SPTID%,SX%,SY%,SIMAGE$,SW%,SH%,SMAX%,SMIN%) ;Create a Slider

S.SLIDER = New SLIDER
S\PARENT = G
S\SID% = SID%
S\SX% = SX%
S\SY% = SY%
S\SIMAGE = LoadImage(SIMAGE$)
S\SW% = SW%
S\SH% = SH%
S\SMAX% = SMAX%
S\SMIN% = SMIN%

Return True

End Function