How to display the Print Preview window in a top-level form in Visual FoxPro (188887)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q188887

SUMMARY

Visual FoxPro version 6.0 has added the IN WINDOW clause to make it easier to display the Print Preview window in a top-level form.

MORE INFORMATION

In Visual FoxPro version 5.0, it is not possible to enable the Print Preview to display in a top-level form. The Print Preview window is always displayed in the Visual FoxPro desktop, which is not usually displayed with a top-level form. Visual FoxPro 6.0 has changed this; you can now direct the Print Preview window into an existing top-level form by including the IN WINDOW clause in the report form command. The following code demonstrates how the IN WINDOW clause can work with a top-level form:

Sample Code

   * Start of code example
   *
   public oMain
   oMain = CREATEOBJECT('main')  && open main form
   oMain.visible = .t.
   CREATE TABLE table_1 (field1 C(10))
   FOR lnI=1 TO 3
      INSERT INTO table_1 VALUES ('xx')
   ENDFOR

   CREATE REPORT report_1 FROM table_1

   **************************************************
   *-- Class:        main
   *-- ParentClass:  form
   *-- BaseClass:    form
   *
   DEFINE CLASS main AS form

     Top = 0
     Left = 0
     Height = 165
     Width = 220
     DoCreate = .T.
     Caption = "Main"
     Name = "main"
     opform = .F.

     ADD OBJECT command1 AS commandbutton WITH ;
       Top = 24, ;
       Left = 24, ;
       Height = 37, ;
       Width = 157, ;
       Caption = "Show Print Preview", ;
       Name = "Command1"

     ADD OBJECT command2 AS commandbutton WITH ;
       Top = 84, ;
       Left = 24, ;
       Height = 37, ;
       Width = 157, ;
       Caption = "Close", ;
       Name = "Command2"

     PROCEDURE command1.Click
       oPForm = CREATEOBJECT('printpreview')
       oPform.visible = .t.    && open printpreview form
   *******
   * This is the report form command that uses the IN WINDOW Clause.
   * Notice that it uses both WINDOW and IN WINDOW clauses. The WINDOW
   * clause tells the Print Preview window to take on the characteristics
   * of the window, while IN WINDOW tells in what window to display the
   * Print Preview window.
   *******
    REPORT FORM report_1 PREVIEW WINDOW printpreview IN WINDOW printpreview
    ENDPROC

    PROCEDURE command2.Click
      thisform.release
    ENDPROC

   ENDDEFINE
   *
   *-- EndDefine: main
   **************************************************

   DEFINE CLASS printpreview AS form

     ScaleMode = 3
       Top = 0
       Left = 0
       Height = 454
       Width = 641
       ShowWindow = 2
       DoCreate = .T.
       Caption = "Print Preview Window"
       Movable = .T.
       TitleBar = 0
       WindowState = 0
       SizeBox = .F.
       Name = "printpreview"

   ENDDEFINE

   *End of Sample code
				

REFERENCES

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by David Botzenhart, Microsoft Corporation

Modification Type:MajorLast Reviewed:2/16/2005
Keywords:kbhowto KB188887