ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Comment montrer un PDF dans une forme Foxpro   



L'auteur

Mike Gagnon
Canada Canada
Membre Simple
# 0000000025
enregistré le 14/10/2004

Gagnon Mike
Pointe Cla H9R 3K8
de la société Carver Technologies Inc.
Fiche personnelle


Note des membres
18/20
1 vote


Contributions > 08 - ActiveX - (OLE)

Comment montrer un PDF dans une forme Foxpro
# 0000000693
ajouté le 19/05/2009 18:44:42 et modifié le 19/05/2009
consulté 8885 fois
Niveau débutant

Version(s) Foxpro :
VFP 9.0
VFP 8.0
VFP 7.0
VFP 6.0
VFP 5.0

Description

Ce code inclus la vérification de la présence de l'activex Adobe Acrobat Reader avant de rouler la forme.

Code source :
local llOK
llOK=VerifyActiveX("AcroPDF.PDF.1")
If llOK
  Public oform1
  oform1=Newobject("form1")
  oform1.Show
Else
  Messagebox("Activex non présent")
Endif

Return
&&-----------------------------------------

Function VerifyActiveX
Lparameters tcProgID
#Define HKEY_CLASSES_ROOT    -2147483648

Local loReg, lcActiveXFileName, lcCLSID
lcCLSID = ReadRegistryString(HKEY_CLASSES_ROOT, tcProgID + "\CLSID" , "")
llOK = Not Isnull(lcCLSID)
If llOK
  lcActiveXFileName = ReadRegistryString(HKEY_CLASSES_ROOT, "CLSID\" + lcCLSID + "\InprocServer32" , "")
  llOK = Not Isnull(lcActiveXFileName) And File(lcActiveXFileName)
Endif

Return llOK



Define Class form1 As Form


  Top = 0
  Left = 0
  Height = 600
  Width = 800
  DoCreate = .T.
  Caption = "Form1"
  Name = "Form1"


  Add Object olecontrol1 As OleControl With ;
    Top = 12, ;
    Left = 36, ;
    Height = 500, ;
    Width = 700, ;
    Name = "Olecontrol1", ;
    OleClass = "AcroPDF.PDF.1"


  Add Object command1 As CommandButton With ;
    AutoSize = .T., ;
    Top = 550, ;
    Left = 120, ;
    Height = 27, ;
    Width = 96, ;
    Caption = "Chercher PDF", ;
    Name = "Command1"



  Procedure command1.Click
  Local lcPDF
  lcPDF = Getfile("pdf")
  Thisform.olecontrol1.loadFile(lcPDF)
  Endproc


Enddefine
*
*-- EndDefine: form1
**************************************************
Function ReadRegistryString
Lparameters tnHKey, tcSubkey, tcEntry
#Define ERROR_SUCCESS               0
#Define MAX_INI_BUFFERSIZE 256
#Define MAX_INI_ENUM_BUFFERSIZE 16000

Local lnRegHandle, lnResult, lnSize, lcDataBuffer, tnType
Declare Integer RegOpenKey ;
  IN Win32API ;
  INTEGER nHKey,;
  STRING cSubKey,;
  INTEGER @nHandle

Declare Integer RegCloseKey ;
  IN Win32API ;
  INTEGER nHKey
tnHKey=Iif(Type("tnHKey")="N",tnHKey,HKEY_LOCAL_MACHINE)

lnRegHandle=0

*** Open the registry key
lnResult=RegOpenKey(tnHKey,tcSubkey,@lnRegHandle)
If lnResult#ERROR_SUCCESS
  Return .Null.
Endif

*** Need to define here specifically for Return Type
*** for lpdData parameter or VFP will choke.
*** Here it's STRING.
Declare Integer RegQueryValueEx ;
  IN Win32API As RegQueryString;
  INTEGER nHKey,;
  STRING lpszValueName,;
  INTEGER dwReserved,;
  INTEGER @lpdwType,;
  STRING @lpbData,;
  INTEGER @lpcbData

*** Return buffer to receive value
lcDataBuffer=Space(MAX_INI_BUFFERSIZE)
lnSize=Len(lcDataBuffer)
lnType=0

lnResult=RegQueryString(lnRegHandle,tcEntry,0,@lnType,;
  @lcDataBuffer,@lnSize)

=RegCloseKey(lnRegHandle)

If lnResult#ERROR_SUCCESS
  Return .Null.
Endif

If lnSize<2
  Return ""
Endif

*** Return string based on length returned
Return Substr(lcDataBuffer,1,lnSize-1)
Endproc
* ReadRegistryString

Commentaires
le 28/05/2016, mahdi22dz a écrit :
Class not registred ( Comment faire ? )

Publicité

Les pubs en cours :

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2024.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3