Microsoft KB Archive/317466

= How to remove buttons from the Print Preview toolbar =

Article ID: 317466

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q317466



SUMMARY
This article describes how to remove buttons from the Print Preview toolbar and how to use the toolbar in an executable.

This technique applies to Microsoft Visual FoxPro 8.0 and earlier versions. This technique also applies to Visual FoxPro 9.0 when &quot;SET REPORTBEHAVIOR 80&quot; is enabled. With &quot;REPORTBEHAVIOR&quot; set to &quot;90&quot; in Visual FoxPro 9.0, this process is much easier when you use event driven reporting.



MORE INFORMATION
The following steps describe how to remove the Print button from the Print Preview toolbar. The Print button is used as an example. However, any of the buttons can be removed. You may want to remove the Print button, for example, if you want users of your application to be able to preview a report but not to print it.   Paste the following code in a program (.prg) file, and then run the program from the Command window: LOCAL lcResourceFileStem IF '05.'$VERSION &&  Foxtools required in VFP5 SET LIBRARY TO HOME+'foxtools.fll' ENDIF SET SAFETY OFF

lcResourceFileStem = ADDBS(JUSTPATH(SYS(2005)))+JUSTSTEM(SYS(2005)) SET RESOURCE OFF COPY FILE (lcResourceFileStem + &quot;.dbf&quot;) ; TO noprint.DBF COPY FILE (lcResourceFileStem + &quot;.fpt&quot;) ; TO noprint.fpt
 * Copy the current resource file to NoPrint which is
 * used to store changes to the Print Preview toolbar.

USE noprint.DBF EXCLUSIVE ZAP USE CLOSE ALL
 * Remove current settings by deleting all records in the table.

DELETE FILE PrintTest.DBF CREATE TABLE PrintTest (NAME C(30), Address C(20), City C(20), State C(2)) INSERT INTO PrintTest VALUES (&quot;Jodie Garber&quot;, &quot;1234 Jones St&quot;, &quot;Phoenix&quot;, &quot;AZ&quot;) INSERT INTO PrintTest VALUES (&quot;Holly Johnson&quot;, &quot;675 Smith St&quot;, &quot;Chicago&quot;, &quot;IL&quot;) INSERT INTO PrintTest VALUES (&quot;Jack Reacher&quot;, &quot;968 Duvall Street&quot;, &quot;Key West&quot;, &quot;FL&quot;) INSERT INTO PrintTest VALUES (&quot;Beau Borken&quot;, &quot;1515 Main St&quot;, &quot;York&quot;, &quot;MT&quot;)
 * Create a table to use for a simple report and put some data in it.

CREATE REPORT PrintTest FROM PrintTest COLUMN USE IN PrintTest SET RESOURCE TO noprint.DBF REPORT FORM PrintTest PREVIEW NOWAIT IF '05.'$VERSION &&  Turn off Foxtools in VFP5 SET LIBRARY TO ENDIF RETURN  Right-click the Title bar of the Print Preview toolbar, and then click Customize. If the Print Preview toolbar is docked, you can right-click between the buttons of the toolbar. Under Categories, click Print Preview, and then click the Print button and drag it off the toolbar. Click the Close button to close the Customize Toolbar dialog box. Click the Close button on the Print Preview toolbar to close the Print Preview toolbar.  Type the following command in the Command window: SET RESOURCE OFF   Paste the following code in a program (.prg) file, and then run the program from the Command window:
 * Create a report and preview it.

Note: This step is used to demonstrate that the Print button has been removed from the Print Preview toolbar. The code will run in Visual FoxPro 6.0 and later, but the steps that are described earlier can be used in Visual FoxPro 5.0. You can test in Visual FoxPro 5.0 by manually generating a project that has a main program that contains the SET RESOURCE TO NoPrint, and the REPORT FORM command.
 * 1) DEFINE CRLF CHR(13) + CHR(10)

LOCAL cMain

CLOSE ALL DELETE FILE PrintTest.PJ? SET SAFETY OFF cMain = &quot;USE PrintTest &quot; + CRLF
 * Delete any projects with the same name.
 * Open the table used by the report.

cMain = cMain + &quot;SET RESOURCE TO NoPrint&quot; + CRLF cMain = cMain + &quot;REPORT FORM PrintTest PREVIEW&quot; + CRLF
 * Set the resource file to the one that does not have
 * a print button on it.

STRTOFILE(cMain,&quot;Main.Prg&quot;)
 * Save the string cMain to main.prg.

CREATE PROJECT PrintTest NOWAIT _VFP.ActiveProject.Files.Add(&quot;Main.Prg&quot;) _VFP.ActiveProject.Files.Add(&quot;PrintTest.Frx&quot;)
 * Create a project and add all the files that the project needs.

_VFP.ActiveProject.Files.Add(&quot;NoPrint.Dbf&quot;) _VFP.ActiveProject.Files.Item(3).Exclude = .F.
 * Add the resource file that the print button was removed
 * from and include it in the executable. This makes it read only.
 * If the resource file is read only, changes made to the
 * environment at runtime will not be saved.

_VFP.ActiveProject.Build(&quot;PrintTest.Exe&quot;,3,.T., .T.) </li>  Run PrintTest.exe and note that the toolbar does not have a Print button. You can double-click PrintTest.exe in Windows Explorer to run the program, or you can run the following command from the Command window: RUN /N PrintTest.exe </li> Click the Close button on the Print Preview toolbar to close the toolbar.</li></ol>
 * Compile the project into an executable.

Keywords: kbcodesnippet kbhowto kbreportwriter KB317466

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.