
CR 8.0 API PEOutputToWindow (LONG)
Hi to all.
I use the following code to open the print preview window of crystal
reports. I use directly the API calls.
I have copy&paste the CR help files examples but the print preview window
never open.
Here is the code:
Public Sub subCaricaReport(strFileReport As String, MyRPT As itRPT_Engine)
Dim intPEOpenRes As Integer
Dim intJobNum As Integer
Dim intResult As Integer
intPEOpenRes = PEOpenEngine()
[...]
' Apro un job sul report passatomi;
intJobNum = PEOpenPrintJob(strFileReport)
[...]
Dim TableType As PETableType
Dim LogOnInfo As PELogOnInfo
Dim TableLocation As PETableLocation
Dim SessionInfo As PESessionInfo
Dim TestTableType As PETableType
Dim TestLogOnInfo As PELogOnInfo
Dim TestTableLocation As PETableLocation
Dim TestSessionInfo As PESessionInfo
Dim TableCount As Integer
TableType.StructSize = PE_SIZEOF_TABLE_TYPE
LogOnInfo.StructSize = PE_SIZEOF_LOGON_INFO
TableLocation.StructSize = PE_SIZEOF_TABLE_LOCATION
SessionInfo.StructSize = PE_SIZEOF_SESSION_INFO
TestTableType.StructSize = PE_SIZEOF_TABLE_TYPE
TestLogOnInfo.StructSize = PE_SIZEOF_LOGON_INFO
TestTableLocation.StructSize = PE_SIZEOF_TABLE_LOCATION
TestSessionInfo.StructSize = PE_SIZEOF_SESSION_INFO
TableCount = PEGetNTables(intJobNum)
[...]
Dim i As Integer
For i = 0 To TableCount - 1
intResult = PEGetNthTableType(intJobNum, i, TableType)
[...]
intResult = PEGetNthTableLogOnInfo(intJobNum, 0, LogOnInfo)
[...]
intResult = PEGetNthTableLocation(intJobNum, i, TableLocation)
[...]
intResult = PEGetNthTableSessionInfo(intJobNum, i, SessionInfo)
[...]
LogOnInfo.ServerName = App.Path & "\Example\Datavuoto2002.mdb" &
Chr$(0)
intResult = PESetNthTableLogOnInfo(intJobNum, i, LogOnInfo, True)
[...]
Next i
intResult = PEOutputToWindow(intJobNum, "Anteprima di stampa" & Chr$(0),
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0,
MyRPT.OwnerForm.hWnd)
[...]
intResult = PEStartPrintJob(intJobNum, 1)
[...]
Dim lngTemp As Long
lngTemp = 1
Do While lngTemp <> 0
lngTemp = PEGetWindowHandle(intJobNum)
DoEvents
DoEvents
DoEvents
Loop
PEClosePrintJob intJobNum
PECloseEngine
[...]
End Sub
I suppose that seagate's programmers use the last do...while to wait for the
print preview window close. The PEGetWindowHandle API return me always a
non-zero value (so I suppose that the window is created) but the preview
window isn't displayed. Why?
After each API call I use a ErrorTrap function that check if an error occour
and the execution of each API is OK.
If anyone have a valid example...
Best Regards
SebaMix
P.S. Sorry my english :-)