En versiones anteriores a VFP 8.0 no podiamos colorear un Boton de Comandos (CommandButton) ni especificar la posición de una imagen con respecto a su rótulo.
Aquí una clase derivada de un objeto Contenedor que simula un Botón de Comandos y permite estas características.
Simular un Botón con un Contenedor Por Luis María Guayán, Tucumán, Argentina
En el siguiente ejemplo vemos la forma de simular un Botón de Comandos con un objeto Contenedor que imita el comportamiento del evento Click y permite colorear su fondo y distribuir a gusto una imagen y una etiqueta contenidas en él.
PUBLIC oForm
oForm = CREATEOBJECT("MiForm")
oForm.SHOW(1)
DEFINE CLASS MiForm AS FORM
AUTOCENTER = .T.
CAPTION = "Simular un Botón con un Contenedor"
ADD OBJECT MiBoton AS MiBoton
ENDDEFINE
DEFINE CLASS MiBoton AS CONTAINER
TOP = 90
LEFT = 90
HEIGHT = 50
WIDTH = 200
SPECIALEFFECT = 0
BACKCOLOR = RGB(255,255,0)
NAME = "Container1"
ADD OBJECT Image1 AS IMAGE WITH ;
TOP = 10, ;
LEFT = 10, ;
HEIGHT = 25, ;
WIDTH = 25, ;
NAME = "Image1", ;
PICTURE = (HOME(1)+"Fox.bmp")
ADD OBJECT Label1 AS LABEL WITH ;
FONTSIZE = 14, ;
BACKSTYLE = 0, ;
CAPTION = "Presioname!!!", ;
TOP = 15, ;
LEFT = 50, ;
AUTOSIZE = .T., ;
NAME = "Label1"
PROCEDURE CLICK
MESSAGEBOX("Click del Botón",64,"Aviso")
ENDPROC
PROCEDURE MOUSEUP
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF nButton = 1
THIS.LEFT = THIS.LEFT - 1
THIS.TOP = THIS.TOP - 1
ENDIF
ENDPROC
PROCEDURE MOUSEDOWN
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF nButton = 1
THIS.LEFT = THIS.LEFT + 1
THIS.TOP = THIS.TOP + 1
ENDIF
ENDPROC
PROCEDURE Image1.MOUSEDOWN
LPARAMETERS nButton, nShift, nXCoord, nYCoord
THIS.PARENT.MOUSEDOWN(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE Image1.MOUSEUP
LPARAMETERS nButton, nShift, nXCoord, nYCoord
THIS.PARENT.MOUSEUP(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE Image1.CLICK
THIS.PARENT.CLICK
ENDPROC
PROCEDURE Label1.MOUSEUP
LPARAMETERS nButton, nShift, nXCoord, nYCoord
THIS.PARENT.MOUSEUP(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE Label1.MOUSEDOWN
LPARAMETERS nButton, nShift, nXCoord, nYCoord
THIS.PARENT.MOUSEDOWN(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE Label1.CLICK
THIS.PARENT.CLICK
ENDPROC
ENDDEFINE
|