Utilizar una clase que se encuentra compilada en un EXE
Visual Fox Pro, Trucos Comentarios ( 0 ) »Set ClassLib To
MiClase.Vcx In Archivo.Exe Additive
Set ClassLib To
MiClase.Vcx In Archivo.Exe Additive
Local oListener
As ReportListener,
nPageIndex
oListener =
Createobject("ReportListener")
oListener.ListenerType
= 3
cRutaReporte = Home(2)+"Solution\Reports\invoice.frx"
Report Form (cRutaReporte) Preview Object oListener
For nPageIndex=1
To
oListener.PageTotal
cOutputFile =
"c:\tmp"+Trans(nPageIndex)+".bmp"
oListener.OutputPage(nPageIndex,;
cOutputFile, 105, 0,0,768,1024)
&& 105=bitmap
Next
Veamos una constante en VB, el valor de la misma está dada en hexadecimal
Public Const INTERNET_FLAG_RAW_DATA = &H40000000
Y ahora en VFP
#
DEFINE INTERNET_FLAG_RAW_DATA 0x40000000Debes reemplazar Public Const por #DEFINE y el valor reemplazando &H con 0x
Declare Integer GetCurrencyFormat
In
WIN32API ;
Integer
Locale,
Integer
dwFlags,;
String
lpValue,
String
lpFormat,;
String
@lpCurrencyStr,;
Integer
cchCurrency
cBuffer = Replicate(Chr(0),255)
=GetCurrencyFormat(0,0,[5.32],0,@cBuffer,255)
Buffer =
Chrtran(cBuffer,
Chr(0),[])
Messagebox(cBuffer)
Dimension aDatos[10,1]
aDatos[1]
=
"UNO"
aDatos[2]
=
"DOS"
aDatos[3]
=
"TRES"
aDatos[4]
=
"CUATRO"
aDatos[5]
=
"....."
aDatos[6]
=
"DDDDDD"
aDatos[7]
=
"RRRRRR"
aDatos[8]
=
"HHHHHH"
aDatos[9]
=
"....."
aDatos[10]
=
"FFFFFF"
Create Cursor MisDatos (Txt C(12))
Append From Array aDatos
Browse
Public oform1, oForm2
oform1=Newobject("Form1")
oform1.Show
Return
Define Class Form1
As Form
DoCreate = .T.
Caption
=
"Formularios Anclables"
Dockable
= 1
Name
=
"Form1"
Add Object
command1
As CommandButton
;
With Top
= 73, ;
Left
= 103, ;
Height
= 27, ;
Width
= 140, ;
Caption
=
"Mostrar From anclado",
;
Name
=
"Command1"
Procedure
command1.Click
oForm2 =
Newobject([Form2])
oForm2.Show()
oForm2.Dock(4,
Thisform)
EndProc
EndDefine
Define Class Form2
As Form
DoCreate = .T.
Caption
=
"Otro formulario"
Dockable
= 1
Name
=
"Form2"
Add Object
edit1
As EditBox With
;
Height
= 152, ;
Left
= 136, ;
Top
= 29, ;
Width
= 155, ;
Name
=
"Edit1"
EndDefine
oCat = CreateObject("ADOX.Catalog")
oTab = CreateObject("ADOX.Table")
cRutaDB = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ ;
"Data Source=C:\BaseDatos.mdb;"
* Abro el catálogo
oCat.ActiveConnection = cRuta
* Creo la nueva tabla
With oTab
.Name
=
"Tabla Vinculada de dBASE"
.ParentCatalog = oCat
EndWith
* Establezco las propiedades para crear el vínculo con el archivo de dBASE
With oTab
* Indicamos
solamente la carpeta donde se encuentra la tabla
.Properties("Jet
OLEDB:Link Datasource") =
"C:\"
.Properties("Jet
OLEDB:Remote Table Name") =
"vacunas#dbf"
.Properties("Jet
OLEDB:Create Link") = .T.
.Properties("Jet
OLEDB:Link Provider String") =
"dBASE 5.0;"
EndWith
* Añado la tabla a la colección Tables
oCat.Tables.Append(oTbl)
oCat = Null
=MessageBox("Se
ha vinculado correctamente el archivo.")
En el siguiente ejemplo el MessageBox se reemplazará por el Wait Window
#
Define Messagebox NoMsg=
Messagebox("Esto es un mensaje")Procedure
NoMsg(x,y,z)
Y si deseas que no muestre nada sólo quita el Wait Window y listo.
Otro ejemplo; en este vamos hacer que la función ALLTRIM convierta enseguida a mayúsculas
#
Define Alltrim MiAlltrim?
Alltrim(" Esto es un mensaje ")Procedure
MiAlltrim(cTxt)Tengamos en cuenta que dentro del procedimiento no podemos volver a llamar a la función ALLTRIM puesto que se presentaría un llamado recursivo a la misma función (MiAlltrim) a menos que utilice #Undefine Alltrim antes del RETURN.
Otro ejemplo básico, vamos a evitar que se utilice la función VAL
#
Define Val NoxVal?
Val("10")Procedure
NoxVal(cTxt)Bueno, puede hacer muchas cosas, sólo es cuestión de imaginación y necesidades
cDir =
GETENV("userprofile")+"\Configuración local\Application Data\Microsoft\CD Burning\"cFile =
"c:\DatosXP.txt"Copy File
(cFile) to (cDir+JustFname(cFile))Set Safety Off
Create Cursor Tabla1 (Txt C(10))
Insert Into Tabla1
Values
("XXXXXXXXXX")
Insert Into Tabla1
Values
("YYYYYYYYYY")
Insert Into Tabla1
Values
("WWWWWWWWWW")
Create Report Reporte1
From
Tabla1
Report Form Reporte1
Preview Nowait
Create Cursor Tabla2 (Txt C(10))
Insert Into Tabla2
Values
("AAAAAAAA")
Insert Into Tabla2
Values
("BBBBBBBB")
Insert Into Tabla2
Values
("CCCCCCCC")
Create Report Reporte2
From
Tabla2
Report Form Reporte2
Preview Nowait
lEx =
IsExclusive("Tabla")?
Iif(lEx, "Exclusiva", "Compartida")
#DEFINE ImpRangoPag 4
cPaginas = "1,3,6-12"
oWord = CreateObject("Word.Application")
oWord.Documents.Open(GetFile("DOC"))
oWord.ActivePrinter =
GetPrinter()
oWord.ActiveDocument.Printout(.T.,,ImpRangoPag,,,,,1,cPaginas)
oInet = Create("InetCtls.Inet")
oInet.RemotePort =
"8080"
oInet.RequestTimeOut = 1000
* En caso de necesitar Proxy
* oInet.proxy = "192.168.6.3"
cUrl = "http://www.davphantom.net/img/log2.png"
oDatos = oInet.OpenURL(cUrl, 1)
nHF = Fcreate("log2.png")
For i = 1
To Alen(oDatos)
Fwrite(nHF,
Chr(oDatos[i]))
EndFor
FClose(nHF)
Lo único que debes hacer presionar las teclas: Ctrl + C cuando te muestre el MessageBox y ya tendrás en el portapapeles el mensaje que se mostraba.
oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate("http://yahoo.com")
DO WHILE oIe.ReadyState = 1
WAIT WINDOW
"Procesando...."
Nowait
ENDDO
oIEdocument = oIE.Document
?oIEdocument.body.innerhtml