DOCUMENT:Q190069 06-AUG-1999 [foxpro] TITLE :HOWTO: Showing Print Preview as MDI Child of Top-Level Form PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 ------------------------------------------------------------------------------- SUMMARY ======= Starting with Visual FoxPro 5.0, you may create top-level forms that do not require the Visual FoxPro desktop to display. If you display a report preview within a top-level form, you must first display the Visual FoxPro desktop for the report preview to be visible. Visual FoxPro 6.0 has added the capability for displaying report previews within top-level forms. This article describes how to display a report preview as a multiple document interface (MDI) child window within a top- level form, and also shows how to size the preview to the top-level form. MORE INFORMATION ================ Below is an example that demonstrates the display of a report preview as an MDI child of a top-level form. Through code, we create a table and a report, then create and show a top-level form. Once the form is visible, you can display the report preview by clicking the "Report Preview" CommandButton. The preview can be displayed in one of two ways, either in an MDI child window the same size as the top-level form (the default, with the check box selected), or in an MDI child window maximized within the top-level form (by clearing the check box). 1. Run the following code from a program (.prg) file: CLEAR ALL PUBLIC oform LOCAL lnI CLOSE DATA ALL Delete file table_1.dbf CREATE TABLE table_1 (field1 C(10)) FOR lnI = 1 TO 3 INSERT INTO table_1 VALUES ('xx') ENDFOR Delete file report_1.fr? CREATE REPORT report_1 FROM table_1 oform=CREATEOBJECT("TL_form") oform.SHOW() READ EVENTS CLOSE TABLES DEFINE CLASS TL_form AS FORM BorderStyle = 3 ShowWindow = 2 AutoCenter = .T. lIsFormUp=.F. Width = 500 ADD OBJECT commandpreview AS COMMANDBUTTON WITH ; TOP = 180, ; LEFT = 210, ; HEIGHT = 27, ; WIDTH = 95, ; CAPTION = "Report Preview", ; NAME = "Commandpreview" PROCEDURE DESTROY Clear EVENTS _SCREEN.VISIBLE=.T. SET SYSMENU TO DEFAULT ENDPROC PROCEDURE ACTIVATE IF !THIS.lIsFormUp _SCREEN.VISIBLE = .f. && We wait till now to hide desktop && to ensure SDI form is active window. this.lIsFormUp = .T. ENDIF ENDPROC ADD object chkType as checkbox with ; top = 20, ; caption = 'Check to preview in window sized to form, ' ; + 'uncheck to maximize in top level form', ; autosize = .t., ; value = .T., ; backstyle = 0, ; left = 30 PROCEDURE commandpreview.CLICK LOCAL foTemplate, llClosable * Create template form foTemplate = newobj('form') foTemplate.Name = SYS(2015) foTemplate.Caption = "My Report Preview Window" foTemplate.mdiform = .T. foTemplate.top = 0 foTemplate.left = 0 * Size template form to top level form foTemplate.width = thisform.width - 8 && 8 is fudge for border foTemplate.height = thisform.height ; - 8 - sysmetric(9) && sysmetric is for TitleBar height IF !thisform.chkType.value KEYB '{ctrl+f10}' && Maximize the Preview Window ENDIF llClosable = thisform.closable thisform.closable = .f. && Make main form not closable REPORT FORM report_1 PREVIEW WINDOW (foTemplate.name) thisform.closable = llClosable && Restore original setting ENDPROC PROC Init DO do_menu WITH THIS,.T.,.T. ENDPROC ENDDEFINE PROC do_menu && This is stripped down code from Menu Designer menu LPARAMETERS oFormRef, getMenuName, lUniquePopups LOCAL cMenuName, a_menupops m.cMenuName = SYS(2015) DIMENSION a_menupops[1] a_menupops[1]="_mfile" DEFINE MENU (m.cMenuName) IN (m.oFormRef.Name) BAR DEFINE PAD _msm_file OF (m.cMenuName) PROMPT "\