FoxPro/Visual FoxPro - Ver un PDF en un formulario

   
Vista:

Ver un PDF en un formulario

Publicado por Ernesto Hernandez (4632 intervenciones) el 08/11/2007 21:20:24
PUBLIC oform1

oForm1=NEWOBJECT("form1")
oForm1.Show()
RETURN

DEFINE CLASS form1 AS form

Autocenter = .T.
Height = 520
Width = 741
Caption = "Form1"
Name = "Form1"
cPdfFileName = "=SPACE(0)"

ADD OBJECT txtpdfname AS textbox WITH ;
Top = 471, Left = 108, Height = 23, Width = 492, ;
ReadOnly = .T., Name = "txtPdfName"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 469, Left = 623, Height = 27, Width = 84, ;
Caption = "View PDF", Name = "Command1"

ADD OBJECT owb AS olecontrol WITH ;
Top = 24, Left = 12, Height = 433, Width = 709, ;
OleClass = "Shell.Explorer.2", Name = "oWB"

ADD OBJECT label1 AS label WITH ;
Height = 17, Left = 36, Top = 474, Width = 63, ;
Caption = "PDF Name", Name = "Label1"

PROCEDURE Refresh
* Required in VFP8 and earlier to prevent an error
NODEFAULT
ENDPROC

PROCEDURE ShowPdf
* Clear Web browser control by loading blank page
Thisform.oWB.OBJECT.Navigate2("About:Blank")
* Wait for load to complete
lnSeconds = SECONDS()
DO WHILE Thisform.oWB.OBJECT.Busy AND SECONDS() - lnSeconds < 60
DOEVENTS
ENDDO

* Load PDF
Thisform.oWB.OBJECT.Navigate2(Thisform.cPdfFileName)
* Wait for load to complete
lnSeconds = SECONDS()
DO WHILE Thisform.oWB.OBJECT.Busy AND SECONDS() - lnSeconds < 60
DOEVENTS
ENDDO
ENDPROC

PROCEDURE command1.Click
* Get PDF file name
Thisform.cPdfFileName = GETFILE("pdf")
* Display the name in the textbox
Thisform.txtPdfName.Value = Thisform.cPdfFileName
IF NOT EMPTY(Thisform.cPdfFileName)
* Display PDF
Thisform.ShowPdf()
ENDIF
ENDPROC

ENDDEFINE
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ver un PDF en un formulario

Publicado por Pablo (1 intervención) el 18/11/2007 22:09:17
Tenés idea por que me tira error en el Form1.Show() ?

El error es "Codigo de Error OLE 0x80004005: Codigo de Estado de COM desconocido."

Gracias,
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar