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 ENDDEFINELuis María Guayán
Nice one!
ResponderBorrarA few small things :
- I press the left mouse button and I move the mouse outside the container
- I press the left mouse button, I move the mouse outside the container; outside the container, keeping the left mouse pressed, I press the right mouse button; then I release first the right,and finally the left mouse button
- I press the left mouse button, I move the mouse outside the form; outside the form I release the button