Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Yet another form flashes problem
Message
De
22/06/2007 16:45:11
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Yet another form flashes problem
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01235113
Message ID:
01235113
Vues:
64
Hi all,
Here is yet another "form flashes and disappears" problem! I must be getting into my dotage but I can't seem to see the answer.

I have what should be a dirt simple situation. I instantiate one form that displays a list of PDFs. The user picks one and I instantiate another form to display the PDF with Acrobat Reader. The file display form shows properly. The reader form will instantiate just fine, displaying the PDF, but then vanishes! I've tried everything I can think of, but no luck. Any insights welcome!

I'm surely missing something simple here. simplified code follows:

*--MAIN.PRG in case the EXE is called directly
LPARAMETERS tcMemberID, tcSourceDir

SET SAFETY OFF
_screen.Visible = .F.

oViewer = CREATEOBJECT('Viewer')
oViewer.LoadFiles(tcMemberID, tcSourceDir)

RETURN

*-- Can be called as a COM object
DEFINE CLASS Viewer as Custom OLEPUBLIC

PROCEDURE LoadFiles
LPARAMETERS tcMemberID as String, tcSourceDir as String

LOCAL oForm

SET SAFETY OFF
_screen.Visible = .F.

oForm = CREATEOBJECT('PDFPicker', tcMemberID, tcSourceDir)
IF TYPE('oForm') = 'O'
oForm.Show()
READ EVENTS && Works like a champ, PDFPicker stays visible
ENDIF

IF _vfp.StartMode > 0
QUIT
ELSE
_screen.Visible = .T.
ENDIF
ENDPROC

ENDDEFINE


DEFINE CLASS PDFPicker AS FORM

Height = 301
Width = 231
ShowWindow = 2
DoCreate = .T.
AutoCenter = .T.
Caption = "Document Picker"
WindowType = 0
AlwaysOnTop = .F.
csourcedir = ""
Name = "PDFPicker"
DIMENSION afiles[1,2]

ADD OBJECT lstFiles AS listbox WITH ;
RowSourceType = 5, ;
Height = 235, ;
Left = 7, ;
Top = 5, ;
Width = 217, ;
Name = "lstFiles"

ADD OBJECT cmdViewPDF AS commandbutton WITH ;
Top = 263, ;
Left = 81, ;
Height = 25, ;
Width = 69, ;
Caption = "View", ;
Name = "cmdViewPDF"

PROCEDURE Init
LPARAMETERS tcMemberID, tcSourceDir

*-- Form instantiates fine, loads file list and waits
ENDPROC

PROCEDURE cmdViewPDF.Click
LOCAL cFileName
LOCAL oForm

IF this.Parent.lstFiles.ListIndex > 0

cFilename = thisform.aFiles[thisform.lstFiles.ListIndex, 2]

IF FILE(cFileName)
oForm = CREATEOBJECT('PdfViewer')
oForm.DisplayPdf(cFileName)
oForm.Visible = .T.

SET STEP ON
*-- Form is visible with pdf loaded, but code keeps executing

*-- None of the following do squat!
*****************************
oForm.Show()
READ EVENTS
*****************************
oForm.Show(1)
*****************************
oForm.Show()
*****************************
READ EVENTS
*****************************

ENDIF

ELSE
MESSAGEBOX([No PDF selected!])
ENDIF

ENDPROC

PROCEDURE QueryUnload
CLEAR EVENTS
ENDPROC


ENDDEFINE

DEFINE CLASS PdfViewer AS FORM

HEIGHT = 623
WIDTH = 1009
MAXHEIGHT = 623
MAXWIDTH = 1009
MINHEIGHT = 200
MINWIDTH = 300
AutoCenter = .T.
AlwaysOnTop = .T.
ShowWindow = 2
WindowType = 1
DoCreate = .T.

CAPTION = "REEDS PDF Viewer"
NAME = "PdfViewer"

ADD OBJECT AcrobatViewer AS OLECONTROL WITH ;
OLECLASS = "AcroPDF.PDF.1", ;
NAME = "AcrobatViewer",;
Visible = .T.

PROCEDURE DisplayPdf
LPARAMETERS tcFileName

WITH THIS.AcrobatViewer
.TOP = 2
.LEFT = 2
.HEIGHT = THIS.HEIGHT-5
.WIDTH = THIS.WIDTH-5
.loadfile(tcFileName)
.ANCHOR = 10
ENDWITH
ENDPROC

ENDDEFINE
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform