PUBLIC goTestForm &&As Form goTestForm = CREATEOBJECT('Form') goTestForm.Addobject('FancyBtn', 'FancyButton') goTestForm.FancyBtn.Visible = .T. goTestForm.Show DEFINE CLASS FancyButton AS Container SpecialEffect = 0 Height = 27 Width = 84 Caption = "Test" && User defined property -if you need pictures on the button you should add image controls ToolTipText = "" PROCEDURE Init This.AddObject('CommandBtn', 'FancyButtonCmdBtn') This.AddObject('Label', 'FancyButtonLabel') This.CommandBtn.Visible = .T. * The next lines are added to fire the assign methods - do not remove them! This.Label.Visible = .T. This.Caption = This.Caption This.ToolTipText = This.ToolTipText This.Width = This.Width This.Height = This.Height This.BackColor = This.BackColor ENDPROC PROCEDURE Destroy ENDPROC PROCEDURE MouseDown LPARAMETERS nButton, nShift, nXCoord, nYCoord * Visual Effect is done using Visible changing * otherwise SpecialEffect change will not be seen (even with Refresh) This.Visible = .F. This.SpecialEffect = 1 This.Visible = .T. ENDPROC PROCEDURE MouseUp LPARAMETERS nButton, nShift, nXCoord, nYCoord This.Visible = .F. This.SpecialEffect = 0 This.Visible = .T. ENDPROC PROCEDURE Click This.BackColor = GETCOLOR(0) ENDPROC PROCEDURE When && Fictive event fired from the invisible CommandBtn RETURN .T. ENDPROC PROCEDURE Valid && Fictive event fired from the invisible CommandBtn RETURN .T. ENDPROC PROCEDURE GotFocus * here will go code for marking the control as selected (with focus on it) * this can be done using a transparent shape object placed above the label * Should be called from the corresponding event of CommandBtn ENDPROC PROCEDURE LostFocus * here will go code for unmarking the control as selected (with focus on it) * so the transparent shape object should be hiden or removed * Should be called from the corresponding event of CommandBtn ENDPROC PROCEDURE BackColor_Assign LPARAMETERS vnNewValue This.BackColor = vnNewValue This.SetAll('BackColor', vnNewValue) ENDPROC PROCEDURE Caption_Assign LPARAMETERS vcNewValue This.Caption = vcNewValue This.SetAll('Caption', vcNewValue) ENDPROC PROCEDURE ToolTipText_Assign LPARAMETERS vcNewValue This.ToolTipText = vcNewValue This.SetAll('ToolTipText', vcNewValue) ENDPROC PROCEDURE Width_Assign LPARAMETERS vnNewValue This.Width = vnNewValue This.Label.Width = vnNewValue - 4 ENDPROC PROCEDURE Height_Assign LPARAMETERS vnNewValue This.Height = vnNewValue This.Label.Height = vnNewValue - 4 ENDPROC * For some other properties you will need assign methods too ENDDEFINE DEFINE CLASS FancyButtonCmdBtn AS CommandButton Style = 1 Top = -1 Left = -1 Height = 1 Width = 1 PROCEDURE Init DECLARE Sleep IN WIN32API Long vnWaitMiliSecs ENDPROC PROCEDURE Click * Called MouseDown & MouseUp to make it visual look like "Click" This.Parent.MouseDown(1, 0, 0, 0) && This parameters can be changed if needed Sleep(75) This.Parent.MouseUp(1, 0, 0, 0) This.Parent.Click ENDPROC PROCEDURE When RETURN This.Parent.When() ENDPROC PROCEDURE Valid RETURN This.Parent.Valid() ENDPROC ENDDEFINE DEFINE CLASS FancyButtonLabel AS Label Top = 2 Left = 2 PROCEDURE Click This.Parent.Click ENDPROC PROCEDURE MouseDown LPARAMETERS nButton, nShift, nXCoord, nYCoord This.Parent.MouseDown(nButton, nShift, nXCoord, nYCoord) ENDPROC PROCEDURE MouseUp LPARAMETERS nButton, nShift, nXCoord, nYCoord This.Parent.MouseUp(nButton, nShift, nXCoord, nYCoord) ENDPROC ENDDEFINE
Make solutions, not programs!