Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to speed this up?
Message
 
 
À
16/05/2006 17:18:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01122411
Message ID:
01122559
Vues:
20
I leave this for now as my final solution (as of tonight <g>):
***********************************************************************************************
*  Program...........: PRINTPDF2
*  Author............: Tracy Holzer
*  Project...........: Visual Collections
*  Created...........: 04/14/2005  12:55:23
*  Copyright.........: (c) Jzanus LTD, 2005
*) Description.......: This function prints PDF passed as parameter and kills Adobe afterwards
*  Calling Samples...:
*  Parameter List....: tcPDF
*  Major change list.:
function PrintPDF2
lparameters tcPDF

wait window "System Printing PDF File......" nowait
if vartype(m.tcPDF)<>"C" or adir(laFile, m.tcPDF) = 0
	tcPDF = getfile("PDF","Select PDF file to print...")
endif
local llReturn, lcStartupInfo, lcProcInfo, hProcess, ;
	lnPrio, lnIBelieve1, ExitCode, lnCount, hThread, lcApp
lnIBelieve1 = 1   && Don't remember what that was
lnPrio = 32 && Priority of Process=Normal
lcStartupInfo = chr(68) + replicate(chr(0), 67)
lcProcInfo = replicate(chr(0), 16)
lcApp = FindApplication(m.tcPDF)
local ltStartTime
ltStartTime = datetime()

llReturn = .t.

if not empty(m.tcPDF)

	declare integer CreateProcess in kernel32;
		integer lpAppName, string lpCmdLine, integer lpProcAttr,;
		integer lpThrAttr, integer bInhHandles, integer dwCrFlags,;
		integer lpEnvir, integer lpCurDir, ;
		string @lpStInfo, string @lpProcInfo
	declare integer GetLastError in kernel32
	declare integer CloseHandle in kernel32 integer hObject
	declare integer WaitForSingleObject in kernel32;
		integer hHandle, integer dwMilliseconds
	declare integer GetExitCodeProcess in WIN32API integer hProcess, integer @lpExitCode
	declare Sleep in kernel32 integer dwMilliseconds

	if CreateProcess(0, m.lcApp + " /p /h" + m.tcPDF + chr(0), 0, 0, ;
			m.lnIBelieve1, m.lnPrio, 0, 0, @lcStartupInfo, @lcProcInfo) <> 0
		hProcess = Buf2DWord(substr(m.lcProcInfo, 1,4))
		hThread = Buf2DWord(substr(m.lcProcInfo, 5,4))
		lnCount = 0
		doevents
		do while .t.
			ExitCode = 0               && initialize return value to 0
			= GetExitCodeProcess(m.hProcess, @ExitCode)   && try to obtain process exit code
			if m.ExitCode # 259            && not still busy
				exit                     && fall out of loop
			else
				lnCount = m.lnCount + 1
				if m.lnCount < 45
*
				else
					exit
				endif
			endif
			= Sleep (100)               && wait .1 seconds
		enddo
		= Sleep(1000)
		= SendData('Adobe Reader')
		= CloseHandle(m.hThread)
		= CloseHandle(m.hProcess)
	else
		=messagebox("Unable to initiate AcroRd32.Exe")
	endif
endif
=messagebox(datetime() - m.ltStartTime)
return

function Buf2DWord(tcBuffer)
return asc(substr(m.tcBuffer, 1,1)) + ;
	asc(substr(m.tcBuffer, 2,1)) * 256 + ;
	asc(substr(m.tcBuffer, 3,1)) * 65536 + ;
	asc(substr(m.tcBuffer, 4,1)) * 16777216
return

*------------------
function SendData
lparameters tcTitle

declare integer FindWindow in Win32API as FindWindow string, string
local lnWindow
lnWindow = FindWindow(0, m.tcTitle)

if m.lnWindow > 0
	#define WM_CLOSE 16
	#define WM_KEYDOWN  0x0100
	#define WM_SYSCOMMAND  0x0112
	#define WM_COMMAND 0x00110818
	#define WM_KEYUP 0x0101
	#define WM_SETFOCUS 0x0007

	declare SHORT PostMessage in user32 ;
		integer   hwnd, integer Msg, string wParam, ;
		integer   lparam

	ReturnValue = PostMessage(m.lnWindow, WM_CLOSE, 0, 0)
	return .t.
else
	return .f.
endif
************************************************************
*  FUNCTION FindApplication()
************************************************************
*  Author............: VCS  Developers Team
*  Project...........: Visual Collections System
*  Created...........: 05/16/2006  23:00:03
*  Copyright.........: (c) Jzanus, 2006
*) Description.......:
*  Calling Samples...:
*  Parameter List....:
*  Major change list.:
function FindApplication
lparameters tcFile

declare integer FindExecutable in shell32 string, string, string @
local lcApp, lcFile, lcDir
lcApp = replicate(chr(0), 255)
lcFile = justfname(m.tcFile) + chr(0)
lcDir = justpath(m.tcFile) + chr(0)
= FindExecutable(m.lcFile, m.lcDir, @lcApp)
return m.lcApp
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform