* The parent container class might look like this DEFINE CLASS cntButtonClass as Container * State is left digit of tag "0"=None,"1"=Mixed ON, * "2"=Mixed OFF,"3"=Enabled,"4"/Disabled top=3 height=24 width=24 backstyle=0 borderwidth=0 style=3 &&Themed visible=.t. PROCEDURE MouseDown (nButton, nShift, nXCoord, nYCoord) IF this.enabled this.Style= 0 this.BackStyle=0 this.specialeffect= 1 ELSE ENDIF ENDPROC PROCEDURE MouseEnter (nButton, nShift, nXCoord, nYCoord) IF this.Enabled this.backStyle= 1 this.BorderWidth=1 ELSE ENDIF ENDPROC PROCEDURE MouseLeave (nButton, nShift, nXCoord, nYCoord) this.backStyle= 0 this.BorderWidth=0 ENDPROC PROCEDURE Mouseup (nButton, nShift, nXCoord, nYCoord) this.Style= 3 this.BackStyle=1 this.specialeffect=2 ENDPROC PROCEDURE click IF this.tag=[4] && Disabled *Do nothing ELSE runSomething(this.name) ENDIF ENDPROC ADD OBJECT imgButtonAble as imgButtonClass ADD OBJECT imgButtonDisable as imgButtonClass ENDDEFINE &&CLASS cntButtonClass as ContainerYou'd also need a routine to manage the state of the button when clicked or, for example, an alternative process services the process a button click does
PROCEDURE buttonProgramaticEnable(oButton as Container,lEnable as logical) WITH oButton IF lEnable AND .tag=[4] OR !lEnable AND .tag=[3] .imgButtonAble.visible=lEnable &&!this.imgButtonAble.visible .imgButtonDisable.visible=!lEnable &&!this.imgButtonDisable.visible .Enabled=lEnable .tag=IIF(lEnable,[3],[4]) ELSE && Just leave it alone ENDIF ENDWITH ENDPROC &&buttonProgramaticEnable(oButton,lEnable)You need the image class. This one has an enabled and disabled image and is added to the button class at instantiation
DEFINE CLASS imgButtonClass as Image top=1 left=1 height=22 width=22 backstyle=0 backcolor=RGB(255,255,255) stretch=0 PROCEDURE init this.tooltiptext=this.Parent.tooltiptext ENDPROC PROCEDURE MouseDown (nButton, nShift, nXCoord, nYCoord) this.Parent.MouseDown (nButton, nShift, nXCoord, nYCoord) ENDPROC PROCEDURE MouseUp (nButton, nShift, nXCoord, nYCoord) this.Parent.MouseUp (nButton, nShift, nXCoord, nYCoord) ENDPROC PROCEDURE MouseEnter (nButton, nShift, nXCoord, nYCoord) this.Parent.MouseEnter (nButton, nShift, nXCoord, nYCoord) ENDPROC PROCEDURE MouseLeave (nButton, nShift, nXCoord, nYCoord) this.Parent.MouseLeave (nButton, nShift, nXCoord, nYCoord) ENDPROC PROCEDURE click this.parent.click ENDPROC ENDDEFINE* You might want a separator to put between the buttons:
DEFINE CLASS cntSeperatorClass as Container top=3 height=25 width=2 style=0 &&Normal specialeffect=1 && Sunken backstyle = 0 && Transpartentb visible=.t. ENDDEFINENext the subclass
DEFINE CLASS cntHelpClass as cntButtonClass tag=[0] visible=.t. Tooltiptext=[Open the help screen] PROCEDURE init this.imgButtonAble.Picture=("tix\helpable.gif") this.imgButtonDisable.Picture=("tix\helpdisable.gif") this.imgButtonAble.visible=.t. this.imgButtondisable.visible=.f. ENDPROC ENDDEFINE* And finally - after all that you'd want to put you buttons in a tool bar (container)
DEFINE CLASS cntToolBarClass as Container *LEFT_FOR_SEPERATOR_AFTER_TB_BUTTON 27 *LEFT_FOR_TB_BUTTON_AFTER_SEPERATOR 5 *LEFT_FOR_TB_BUTTON_AFTER_TB_BUTTON 27 *LEFT_FOR_MB_BUTTON_AFTER_TB_BUTTON 24 *LEFT_FOR_SEPERATOR_AFTER_MB_BUTTON 12 top=3 left=LEFT_PANEL_LEFT height=30 style=3 backstyle=1 width=WIDTH_PAGEFRAME-4 && Note these guys look great on top of a page object ADD OBJECT cntHelp as cntHelpClass && Width 24 cntClose.left=3 ADD OBJECT s1 as cntSeperatorClass && WIdth 2 s1.left=this.cntClose.left+LEFT_FOR_SEPERATOR_AFTER_TB_BUTTON visible=.t. ENDDEFINE* Then a click event
PROCEDURE runSomething(pcButtonName as string) IF pcButtonName="CNTHELP" runOpenHelpForm() ELSE ENDIF ELSE ENDIF ENDPROCIt took me a week to figure it out. Once you get the static images working, you could substitute a timer/image service to get the effect you're looking for.