WAIT WINDOW DATE() WAIT WINDOW _Screen WAIT WINDOW _Screen.ForeColor
VFP Tips & Tricks - Drew Speedie
WAIT WINDOW DATE() WAIT WINDOW _Screen WAIT WINDOW _Screen.ForeColor
_SCREEN.ADDOBJECT("oImagen","MiImagen") WITH _Screen.oImagen .PICTURE = "C:\MiImagen.jpg" .LEFT = INT(_SCREEN.WIDTH - .WIDTH)/ 2 .TOP = INT(_SCREEN.HEIGHT - .HEIGHT)/ 2 .VISIBLE = .T. ENDWITH BINDEVENT(_SCREEN,"Resize",_SCREEN.oImagen,"MiMetodo") DEFINE CLASS MiImagen AS IMAGE PROCEDURE MiMetodo WITH THIS .LEFT = INT(_SCREEN.WIDTH - .WIDTH)/ 2 .TOP = INT(_SCREEN.HEIGHT - .HEIGHT)/ 2 ENDWITH ENDPROC PROCEDURE DESTROY UNBINDEVENT(THIS) ENDPROC ENDDEFINE
loMiForm = CREATEOBJECT("MiForm") loMiForm.SHOW(1) RETURN DEFINE CLASS MiForm AS FORM HEIGHT = 400 WIDTH = 500 AUTOCENTER = .T. CAPTION = "Redimensionar el formulario..." NAME = "MiForm" ADD OBJECT text1 AS TEXTBOX WITH ; HEIGHT = 25, LEFT = 125, TOP = 125, WIDTH = 300, ; NAME = "Text1", VALUE = "Comunidad VFP en Español" ADD OBJECT text2 AS TEXTBOX WITH ; HEIGHT = 25, LEFT = 125, TOP = 200, WIDTH = 300, ; NAME = "Text2", VALUE = "Nada corre como un zorro" ADD OBJECT image1 AS IMAGE WITH ; PICTURE = HOME(2) + "data\graphics\pattcaro.gif", ; HEIGHT = 20, LEFT = 12, TOP = 12, WIDTH = 20, ; NAME = "Image1", STRETCH = 0 PROCEDURE RESIZE THIS.Image1.LEFT = INT(THISFORM.WIDTH - THIS.Image1.WIDTH)/ 2 THIS.Image1.TOP = INT(THISFORM.HEIGHT - THIS.Image1.HEIGHT)/ 2 ENDPROC PROCEDURE image1.INIT THIS.LEFT = INT(THISFORM.WIDTH - THIS.WIDTH)/ 2 THIS.TOP = INT(THISFORM.HEIGHT - THIS.HEIGHT)/ 2 THIS.ZORDER(1) ENDPROC ENDDEFINE
Puesto que el comando USE IN falla si el Alias elegido no está en uso, los desarrolladores de VFP publican con frecuencia el comando USE IN como esto:
IF USED("AlgunAlias") USE IN AlgunAlias ENDIF
Sin embargo, lo antedicho se puede lograr con la siguiente equivalecia en una sola línea:
USE IN SELECT("AlgunAlias")Esto tiene compatibilidad hacia atrás por lo menos hasta FoxPro 2.6.
[061] VFP Tips & Tricks - Drew Speedie
Aquí está la mejor técnica que he visto para comprobar si una variable de memoria o propiedad es un Array.
IF TYPE("ALEN(AlgunaVariable)") = "N" * Si es un Array ELSE * NO es un Array ENDIF
[021] VFP Tips & Tricks - Drew Speedie
_oBrowser.SetDefaultFile()Si desea limpiar la clase por defecto ejecute lo siguiente:
_oBrowser.ResetDefaultFile()Funciona muy bien si está constantemente modificando clases desde la biblioteca de clases por un largo período de tiempo.
DO (_browser) WITH "examples\CPhkBase2, examples\demo"Lista de los usados recientemente
USE MiTablaSCATTER NAME Objeto ADDITIVE
PUBLIC oMiForm oMiForm = CREATEOBJECT("MiForm") oMiForm.SHOW(1) RETURN DEFINE CLASS MiForm AS FORM TOP = 10 LEFT = 10 HEIGHT = 180 WIDTH = 324 CAPTION = "Guardar posición, tamaño y color de fondo" BACKCOLOR = RGB(200,220,255) NAME = "frmMiForm" ADD OBJECT cmdColor AS COMMANDBUTTON WITH ; TOP = 12, LEFT = 12, HEIGHT = 27, WIDTH = 132, ; CAPTION = "Cambiar BackColor", NAME = "cmdColor" ADD OBJECT cmdSalir AS COMMANDBUTTON WITH ; TOP = 48, LEFT = 12, HEIGHT = 27, WIDTH = 132, ; CAPTION = "Salir", NAME = "cmdSalir" ADD OBJECT lblAyuda AS LABEL WITH ; AUTOSIZE = .T., WORDWRAP = .T., BACKSTYLE = 0, ; CAPTION = "Cambie la posición, tamaño y color del " + ; "formulario. Salga del formulario y ejecutelo nuevamente.", ; FONTSIZE = 12, LEFT = 12, TOP = 96, NAME = "lblAyuda" PROCEDURE INIT THISFORM.InicializarPropiedades() THISFORM.TomarPropiedades() THISFORM.RESIZE ENDPROC PROCEDURE DESTROY THISFORM.GuardarPropiedades() ENDPROC PROCEDURE RESIZE THISFORM.lblAyuda.WIDTH = THISFORM.WIDTH - 24 ENDPROC PROCEDURE InicializarPropiedades LOCAL lcScx *-- Creo propiedades THISFORM.ADDPROPERTY("Prop_Alias") THISFORM.ADDPROPERTY("Prop_Tabla") *-- Nombre de la tabla de propiedades lcScx = SYS(1271,THISFORM) THISFORM.Prop_Alias = "_Prop_" + IIF(EMPTY(lcScx),"Form",JUSTSTEM(lcScx)) THISFORM.Prop_Tabla = FORCEEXT(FULLPATH("")+ THISFORM.Prop_Alias, "DBF") *-- Si no existe la tabla la creo IF NOT FILE(THISFORM.Prop_Tabla) CREATE TABLE (THISFORM.Prop_Tabla) FREE ; (TOP I, LEFT I, WIDTH I, HEIGHT I, BACKCOLOR I) APPEND BLANK GATHER NAME THISFORM USE IN SELECT(THISFORM.Prop_Alias) ENDIF ENDPROC PROCEDURE TomarPropiedades *-- Tomo las propiedades de la tabla SELECT 0 USE (THISFORM.Prop_Tabla) SCATTER NAME THISFORM ADDITIVE USE IN SELECT(THISFORM.Prop_Alias) ENDPROC PROCEDURE GuardarPropiedades *-- Guardo las propiedades en la tabla SELECT 0 USE (THISFORM.Prop_Tabla) GATHER NAME THISFORM USE IN SELECT(THISFORM.Prop_Alias) ENDPROC PROCEDURE cmdColor.CLICK THISFORM.BACKCOLOR = GETCOLOR(THISFORM.BACKCOLOR) ENDPROC PROCEDURE cmdSalir.CLICK THISFORM.RELEASE ENDPROC ENDDEFINEPara terminar
DO FORM (HOME(2) + "Solution\Toledo\ScatterName")
CREATE CURSOR csrTEMPORAL(campo1 C(100), campo2 C(100), cAMPO3 C(100), CAMPO7 C(100)) FOR I = 1 TO 150 INSERT INTO csrTEMPORAL VALUES(CDOW(DATE()+i),CDOW(DATE()+i+1),CDOW(DATE()+2),CDOW(DATE()+3)) ENDFOR cDataSource = "Test" cUserName = "root" cPassword = "root" ConnectionString = [DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=] + ; cDataSource + [;USER=] + cUserName + [;PASSWORD=] + cPassword + [;OPTION=3;] nConexion = SQLSTRINGCONNECT( ConnectionString ) SELECT csrTEMPORAL lcComando = "" SCAN lcComando = lcComando + [("] + ALLTRIM(csrTEMPORAL.CAMPO1) + [","] + ; ALLTRIM(csrTEMPORAL.CAMPO2) + [","] + ALLTRIM(csrTEMPORAL.CAMPO3) + ; [","] + ALLTRIM(csrTEMPORAL.CAMPO7) + ["),] ENDSCAN lcComando = [INSERT INTO TEMPORAL (CAMPO1, CAMPO2, CAMPO3, CAMPO7) VALUES ] + ; SUBSTR(lcComando,1,LEN(lcComando)-1) ? lcComando lnSegundos = SECONDS() x = SQLEXEC(nConexion ,lcComando) MESSAGEBOX(SECONDS()-lnSegundos) x = SQLEXEC(nConexion, "SELECT * FROM TEMPORAL", "csrTemporalSQL") x = SQLDISCONNECT(0)Lic. J. Enrique Ramos Menchaca