Ken,
>I am trying to control the crystal report preview window location and size
>with no luck. also the preview appears for a a half second then disappears.
>could you tell me what I am doing wrong.
>
>DECLARE INTEGER GetActiveWindow IN Win32API
>LOCAL lnhwnd
>lnhwnd = GetActiveWindow()
>tcrptname="C:\Seagate Software\Crystal Reports\womasbydept.rpt"
>reportapp=createobject("Crystal.CRPE.Application")
>orpt = reportapp.OpenReport(tcRPTName)
>orpt.PrintWindowOptions.HasPrintSetupButton =.t.
>orpt.PrintWindowOptions.HasSearchButton =.t.
>orpt.PrintWindowOptions.HasexportButton =.t.
>orpt.PrintWindowOptions.HascancelButton =.t.
>orpt.PrintWindowOptions.hasZoomControl=.t.
>orpt.Preview("Title", 12, 23, 624, 643,2,lnhwnd)
>*orpt.Preview
The variable orpt goes out of scope and thereby releasing the report. The best way to solve this problem is to assign the preview to a form property.
The best way to control the Preview i've found is to use the FoxHwnd activeX control. This control (in the example named FOXHNWD) provides a HWND in which the preview can be displayed.
DECLARE INTEGER GetWindow IN user32.DLL INTEGER, INTEGER
DECLARE SetWindowPos IN win32api INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER
THISFORM.TOP=5
THISFORM.LEFT=5
THISFORM.WIDTH=_SCREEN.WIDTH-15
THISFORM.HEIGHT=_SCREEN.HEIGHT-35
THISFORM.PREVIEW=THISFORM.crEngine.Report.PREVIEW("", 0, 0, THISFORM.Width, THISFORM.Height, 33554432, THISFORM.FoxHwnd.hwnd)
THISFORM.Resize
In the resize event of the form put:
THISFORM.wind.Move(0, -2, THISFORM.Width, THISFORM.Height+2)
=SetWindowPos(GetWindow(THISFORM.FoxHwnd.hwnd, 5), 0, -2, 0, THISFORM.Width+1, THISFORM.HEight+3, 2)
HTH
Walter,