GFPalette/GFPalettemod.bas
Attribute VB_Name = "GFPalettemod"
Option Explicit
'(c)2001 by Louis. Use to show/hide a set of controls.
'
'NOTE: the code of this module can be used to create control palettes
'that can be enabled/disabled, e.g. for a setup process that has
'several steps.
'The GFPalette code does not support multiple palette instances yet.
'Note that every added control must have a .Visible property.
'
'NOTE: always add 1 for Reserved (future palette instance index).
'
'PaletteControlStruct ‑ stores references to controls to show/hide
Private Type PaletteControlStruct
ControlObject As Object
ControlPalette As Integer
End Type
Dim PaletteControlStructNumber As Integer
Dim PaletteControlStructArray() As PaletteControlStruct
Dim PaletteIndex As Integer 'current palette index
Public Sub GFPalette_AddControl(ByVal Reserved As Integer, ByRef ControlObject As Control, ByVal ControlPalette As Integer)
'on error resume next
If Not (PaletteControlStructNumber = 32767) Then 'verify
PaletteControlStructNumber = PaletteControlStructNumber + 1
Else
MsgBox "internal error in Palette_AddControl() (GFPalette): overflow !", vbOKOnly + vbExclamation
Exit Sub 'error
End If
ReDim Preserve PaletteControlStructArray(1 To PaletteControlStructNumber) As PaletteControlStruct
Set PaletteControlStructArray(PaletteControlStructNumber).ControlObject = ControlObject
PaletteControlStructArray(PaletteControlStructNumber).ControlPalette = ControlPalette
End Sub
Public Sub GFPalette_DoPaletteChange(ByVal Reserved As Integer, ByVal PaletteIndexNew As Integer)
'on error resume next
Dim ControlLoop As Integer
'preset
PaletteIndex = PaletteIndexNew
'begin
For ControlLoop = 1 To PaletteControlStructNumber 'hide ALL controls
PaletteControlStructArray(ControlLoop).ControlObject.Visible = False
Next ControlLoop
For ControlLoop = 1 To PaletteControlStructNumber 'hide ALL controls
If PaletteControlStructArray(ControlLoop).ControlPalette = PaletteIndex Then
PaletteControlStructArray(ControlLoop).ControlObject.Visible = True 'show control
End If
Next ControlLoop
End Sub
Public Function GFPalette_GetPaletteIndex(ByVal Reserved As Integer) As Integer
'on error resume next 'returns current palette index
GFPalette_GetPaletteIndex = PaletteIndex
End Function
[END OF FILE]