Hello Colin,
I created a test, looks the same like Your test working with a database-field.
Running it, I noticed as well, that WINEXEC calling the Acrobat-reader, but didn't show the pdf-document.
I found a hidden Char at the end of the Arcrobat-path-string comes from the registry.
My path-string was
49 Chars, Len(pathstring) from registry was
50 Chars.
That is the reason, the reader starts without Pdf-file.
My test :
- Code: Select all Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
#define HKEY_LOCAL_MACHINE 2147483650
REQUEST DBFCDX
FUNCTION Main()
local oDlg, oBrw , oCol, nFor, oBtn1, oBtn2, oBnd3, oGet, oSay
c_dir := GetModuleFilename(GetInstance(),"BACKGRD.EXE" + CHR(0), 255)
c_path := left ( c_dir, rat( "\", c_dir) -1 )
DBSELECTAREA(1)
USE CUSTOMER NEW SHARED VIA "DBFCDX"
SET ORDER TO TAG FIRST
GO TOP
cPDF := SPACE(10)
cPDFPATH := SPACE(150)
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE DIALOG oDlg RESOURCE "XBROWSE" FONT oFont
oBrw := TXBrowse():new( oDlg )
oBrw:SetRDD()
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:nColDividerStyle := LINESTYLE_BLACK
oBrw:nRowDividerStyle := LINESTYLE_BLACK
oBrw:nFreeze := 1
oCol := oBrw:AddCol()
oCol:bStrData := { || (1)->FIRST}
oCol:cHeader := "First"
oCol:oDataFont := oFont
oCol := oBrw:AddCol()
oCol:bStrData := { || (1)->LAST}
oCol:cHeader := "Last"
oCol := oBrw:AddCol()
oCol:bStrData := { || (1)->PDFPATH}
oCol:cHeader := "PdfPath"
oBrw:bChange := { || cPDFPATH := ALLTRIM( (1)->PDFPATH ), oSay:Refresh() }
oBrw:CreateFromResource( 110 )
// PDF-File
// -------------
REDEFINE GET oGet VAR cPDF ID 120 OF oDlg UPDATE
// PDF-Path
// -------------
REDEFINE GET oSAY VAR cPDFPATH ID 130 OF oDlg UPDATE
REDEFINE BUTTONBMP oBtn1 ID 30 OF oDlg ;
ACTION ( SAVE_PDF(), cPDFPATH := ALLTRIM( (1)->PDFPATH ), oSAY:Refresh() ) ;
BITMAP "Save" PROMPT "Save" TEXTRIGHT
// 49 Chars
// "e:\programme\adobe\reader 8.0\reader\acrord32.exe"
// 50 Chars from the registry ( 1 Hidden )
// ----------------------------------------------------------------------
REDEFINE BUTTONBMP oBtn2 ID 40 OF oDlg ;
ACTION ( oGet:Refresh(), ;
cRUNPDF := cPDFPATH + " " + ALLTRIM(cPDF) + ".PDF", ;
WinExec( '&cRUNPDF' ) ) ;
BITMAP "Run" PROMPT "Run PDF" TEXTRIGHT
REDEFINE BUTTONBMP oBtn3 ID 50 OF oDlg ;
ACTION ( oDlg:End() ) ;
BITMAP "Quit" PROMPT "Exit" TEXTRIGHT
ACTIVATE DIALOG oDlg CENTER
CLOSE DATABASE
RETURN NIL
// ---------------------
FUNCTION SAVE_PDF()
local nHandle
IF RegOpenKey( HKEY_LOCAL_MACHINE, ;
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths", @nHandle ) == 0
RegQueryValue( nHandle, "ACRORD32.EXE", @cPdfPath )
RegCloseKey( nHandle )
ENDIF
IF ! empty(cPdfPath)
IF MsgYesNo('Save ' + cPdfPath + ' to Company Information')
// Msgalert( LEN( cPdfPath ) ) shows 50 Chars !!!
// My path : "e:\programme\adobe\reader 8.0\reader\acrord32.exe" = 49 Chars
DBSELECTAREA(1)
DBRLOCK()
// 1 Hidden Char found !!!
// ----------------------------
(1)->PDFPATH := SUBSTR(cPDFPATH, 1, LEN(cPDFPATH) -1)
DBUNLOCK()
ENDIF
ELSE
MsgAlert('Cannot Find Acrobat Reader File - Please Install Acrobat Reader')
ENDIF
RETURN( NIL )
*I was trying to get the path to work with WinExec , I tried putting the path in
*a codeblock and evaluating
*bAdobePath := { || oSystem:abobepath }
*WinExec(eval(bAdobePath) + (cPdf))
*I save the path to the adobe reader into a database field so if they update their
*version of adobe reader they can reset the path in the database - this saves originally
*setting the system path on each machine and subsequently change the system path when they
*update.
*database called system contains field adobepath
*cAdobePath := oSystem:adobepath
*My problem is calling that path and the pdf in winexec
*bAdobePath := {|| cAdobePath }
*WinExec(eval(bAdobePath) + (cPdf))
*The adobe reader will open but not with the pdf.
Regards
Uwe