*------------------------------------------ * Usage as a preview container: * _REPORTPREVIEW = "" * * Testing outside of the report system: * DO *------------------------------------------ lparameters oRef if pcount()=0 rl = newobject("ReportListener") rl.ListenerType = 3 report form ? object m.rl x = newobject("myPreview") x.Listener = m.rl x.Show(1) return else oRef = newobject("myPreview") endif return *------------------------------------------------ #define ZOOM_SCALE 1.3 *------------------------------------------------ * The preview frame... *------------------------------------------------ define class myFrame as Container Width = 296 Height = 372 Left = 12 Top = 12 SpecialEffect = 1 BackColor = rgb(192,192,192) add Object target as myTarget enddefine *------------------------------------------------ * ...and its child Shape: *------------------------------------------------ define class myTarget as Shape Height = 330 Width = 255 Left = 20 Top = 20 BackColor = rgb(255,255,255) procedure MouseDown lparameters nButton, nShift, nXCoord, nYCoord offsetX = m.nXCoord - THIS.Left offsetY = m.nYCoord - THIS.Top THISFORM.MousePointer = 5 do while mdown() THIS.Left = mcol(0,3) - m.offsetX THIS.Top = mrow(0,3) - m.offsetY enddo THISFORM.MousePointer = 0 endproc enddefine *------------------------------------------------ * The form class: *------------------------------------------------ define class myPreview as Form Width = 420 Height = 395 BorderStyle = 1 add object frame as myFrame add object cmdPrev as myButton ; with Top=12, Caption = "Previous" add object cmdNext as myButton ; with Top=44, Caption = "Next" add object cmdZoomIn as myButton ; with Top=96, Caption = "Zoom In" add object cmdZoomOut as myButton ; with Top=128, Caption = "Zoom Out" add object cmdReset as myButton ; with Top=176, Caption = "Whole Page" add object cmdClose as myButton ; with Top=220, Caption = "Close" Listener = .null. PageNo = 1 procedure Outputpage() with THIS if not isnull(.Listener) and .Listener.PageTotal > 0 .Listener.OutputPage( ; .PageNo, .Frame.Target, 2, ; 0, 0 , 0 , 0 , ; .Frame.Left +2, ; .Frame.Top +2, ; .Frame.Width -4, ; .Frame.Height -4 ) .Caption = ; justfname(.Listener.commandClauses.file) ; + " - page " + trans(.PageNo) endif endwith endproc procedure Paint() THIS.OutputPage() endproc procedure cmdPrev.Click with THISFORM .PageNo = max(1,.PageNo-1) .OutputPage() endwith endproc procedure cmdNext.Click with THISFORM .PageNo = min(.Listener.PageTotal,.PageNo+1) .OutputPage() endwith endproc procedure cmdZoomIn.Click with THISFORM.Frame.Target .Width = int(.Width * ZOOM_SCALE) .Height = int(.Height * ZOOM_SCALE) endwith THISFORM.OutputPage() endproc procedure cmdZoomOut.Click with THISFORM.Frame.Target .Width = max(17,int(.Width / ZOOM_SCALE)) .Height = max(22,int(.Height / ZOOM_SCALE)) endwith THISFORM.OutputPage() endproc procedure cmdReset.Click with THISFORM.Frame.Target .Top = 20 .Left = 20 .Width = 255 .Height = 330 endwith endproc procedure cmdClose.Click THISFORM.Release() endproc *------------------------------------------- * Methods required for operation * as a Preview Container: *------------------------------------------- procedure SetReport( oRef ) if not isnull(oRef) and vartype(oRef) = "O" THIS.Listener = m.oRef else THIS.Listener = .null. THIS.Hide() endif endproc procedure QueryUnload() nodefault THIS.Release() endproc procedure Release() if not isnull(THIS.Listener) THIS.Listener.OnPreviewClose(.F.) THIS.Listener = .null. endif THIS.Hide() endproc procedure Destroy() THIS.Listener = null dodefault() endproc enddefine *------------------------------------------------ * This button class is used for the form buttons: *------------------------------------------------ define class myButton as CommandButton FontName = "Tahoma" FontSize = 8 Width = 84 Height = 27 Left = 320 enddefine