PSSQA.TXT Answers to Questions About FoxPro Version 2.60a

Last reviewed: April 30, 1996
Article ID: Q121266
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

SUMMARY

The information below is based on the complete FoxPro 2.6a for Windows PSSQA.TXT file found in the main FoxPro directory (usually FPW26).

MORE INFORMATION

                        PSSQA.TXT
**********************************************************
          Answers to Commonly Asked Questions About

    Microsoft(R) FoxPro(R) for Windows(TM) Version 2.6a

    (C)1994 Microsoft Corporation. All Rights Reserved.
**********************************************************

CONTENTS

  1. Cross-Platform
2. Interface Features 3. Report Writer 4. Screen Builder 5. Printer Drivers

Part 1: Cross-Platform

Overview of Questions

  1. Can I create a FoxPro for Windows application using FoxPro for MS-DOS?

  2. I have an existing FoxPro 2.0 project. How do I enable it to run in FoxPro version 2.6?

  3. Will I be able to create executable files for FoxPro version 2.6?

  4. Why doesn't my Low Level File I/O program work in the Windows Product?

Question 1

Can I create a FoxPro for Windows application using FoxPro for MS-DOS?

Answer 1

FoxPro for Windows can execute applications you create with FoxPro for MS-DOS without you making any changes to the appplications. The FoxPro for MS-DOS power tools, however, don't support features that are specific to the Windows environment. You can write your own code to add these Windows features, but we don't recommend this approach to cross-platform application development.

Question 2

I have an existing FoxPro 2.0 project. How do I enable it to run in FoxPro version 2.6?

Answer 2

You open the project in FoxPro version 2.6 and rebuild your application. You must convert screens and reports only if you decide to modify them.

Question 3

Will I be able to create executable files for FoxPro version 2.6?

Answer 3

Yes. The options for building .EXE files in FoxPro 2.6 for MS-DOS are the same as in FoxPro 2.0. You can build compact and stand-alone .EXE files. Compact .EXE files are distributed with library files that are included in the FoxPro Distribution Kit. Stand-alone .EXE files don't require the FoxPro library files. The information from the libraries is built into a stand-alone .EXE.

In FoxPro for Windows, you can create the equivalent of the compact .EXE file. These files are distributed with the library files included in the FoxPro for Windows Distribution Kit.

Question 4

Why doesn't my Low Level File I/O program work in the Windows Product?

Answer 4

FoxPro for Windows can not access the COM ports with the Low Level File commands.

This is documented if you look at the FOPEN() command, but many people who are accustomed to opening a port in the MS-DOS product would test this function and think it is broken.

This is not a bug - it is product design. In the Windows multi-tasking environment, other applications besides FoxPro may also be using the COM ports. It is not desirable to allow a Windows-based application to take exclusive control of the communications port.

Access to the COM port would be provided through FoxTools.FLL and the Windows API calls. In the FPW26\goodies\foxtools directory is a file called dialer.prg This shows an example of using the com port under the Windows environment.

The use of the REGFN() and CALLFN() are documented in the FOXTOOLS.WRI file in the same directory as the example.

Refer to the Windows SDK documentation for information on specific API calls.

Part 2: Interface Features

Overview of Questions

  1. Why do the windows created in FoxPro for Windows have different style controls when compared with the windows in FoxPro for MS-DOS?

  2. What is the purpose of the Control-menu box at the top left of FoxPro windows?

  3. Why is it that some windows in FoxPro can be resized and others can't?

  4. Why have the keyboard shortcuts in FoxPro for Windows been changed? Is there a way to restore the FoxPro for MS-DOS style keystrokes?

  5. When I create a table and press ENTER to add a new field, I find that the dialog unexpectedly closes. Why is this?

  6. FoxPro for Windows automatically displays a status bar located at the bottom of the main window. Is it possible to remove this status bar? Is the MS-DOS-style status bar available?

  7. In FoxPro for Windows, when I issue the command SET DISPLAY TO VGA50 and then the command SET DISPLAY TO VGA25 to restore the previous setting, the status bar disappears. How do I restore the status bar?

  8. Why has the menu for FoxPro for Windows changed? Is the MS-DOS version of the menu available?

  9. The Edit menu contains a number of new options such as Paste Special... and Change Link.... How do I use these options?

  10. The Program menu contains a new option, Beautify. What does it do?

  11. The Text menu is completely new. What new features does this menu

        offer?
    

  12. Occasionally the Object menu is available. When and why is it

        displayed?
    

  13. FoxPro for Windows includes Windows-style help. Is there any way to

        access the .DBF-style help I used in Fox 2.0?
    

  14. Shouldn't I get a full path display rather than just the drive letter

        when I issue the following command in the Command window?
    

        ? SET("DEFAULT")
    

Question 1

Why do the windows created in FoxPro for Windows have different style controls when compared with the windows in FoxPro for MS-DOS?

Answer 1

FoxPro for Windows is designed to conform to the Windows version 3.1 interface guidelines for applications. These guidelines enable you to use the same methods of moving, selecting, and changing windows with all Windows-based applications. FoxPro windows now include Control-menu boxes and Minimize, Maximize, and Restore buttons. For a complete discussion of window styles and terminology, refer to the Getting Started manual.

Question 2

What is the purpose of the Control-menu box at the top left of FoxPro windows?

Answer 2

A single click in the Control-menu box displays the Control menu, with which you can move, size, close, and select windows. A double-click in the Control-menu box closes the window.

Question 3

Why is it that I can resize some windows in FoxPro and not others?

Answer 3

FoxPro for Windows contains windows you can size and windows you can't size. Windows that contain a text-editing region are sizable. Examples of sizable windows are the Command window, Screen Design window, and the Calendar. These windows may contain scroll bars and a sizing box in the bottom right corner of the window. Examples of windows you can't size include the View and RQBE windows. Windows you can't size have only the Control-menu box and the Minimize button.

Question 4

Why have the keyboard shortcuts in FoxPro for Windows changed? Is there a way to restore the FoxPro for MS-DOS style keystrokes?

Answer 4

FoxPro for Windows supports Windows-style keystrokes, such as using ENTER to choose a focused selection. FoxPro for Windows supports both an MS-DOS keystroke mode and Windows keystroke mode. Refer to the FoxPro online help for details on the keystroke differences. You were asked at installation time which mode to select. However, you can change the mode interactively at any time in FoxPro by issuing the command:

   SET KEYCOMP TO DOS

   -or-

   SET KEYCOMP TO WINDOWS

Each time you load FoxPro, the default KEYCOMP setting you specify during installation will be in effect. To change the default setting of KEYCOMP, include the appropriate statement the CONFIG.FPW file:

   KEYCOMP=DOS

   -or-

   KEYCOMP=WINDOWS

Question 5

When I create a table and press ENTER to add a new field, I find that the dialog unexpectedly closes. Why is this?

Answer 5

The keystroke navigation is different in Windows and MS-DOS. In FoxPro for MS-DOS, the keystroke equivalent of clicking the focus button is CTRL+ENTER. In Windows, it is ENTER. So pressing ENTER in the Table Structure dialog tells FoxPro you chose the OK button. To establish the MS-DOS keystroke mode in Windows, issue the command SET KEYCOMP TO DOS.

Question 6

FoxPro for Windows automatically displays a status bar located at the bottom of the main window. Is it possible to remove this status bar? Is the MS-DOS style status bar available?

Answer 6

The Windows-style status bar displays the same information as the MS-DOS style status bar, plus information about the currently selected menu name or command and messages you create using FoxPro commands. It can also display the system time.

The Windows-style status bar is displayed by default. To remove the status bar, in the Command window issue this command:

   SET STATUS BAR OFF

Alternatively, in CONFIG.FPW enter this item:

   STATUS BAR = OFF

To restore the status bar, substitute ON for OFF in the previous two examples.

The SET MESSAGE TO command you use to specify a message location is ignored when the Windows style status bar is active. When the Windows-style status bar is active, messages you create with commands such as DEFINE MENU, DEFINE POPUP, DEFINE BAR, and @...PROMPT appear in the Windows-style status bar.

When the Windows-style status bar is active, to display the time on the right hand side of the status bar issue this command:

   SET CLOCK STATUS

Alternatively, in CONFIG.FPW enter this item:

   CLOCK = STATUS

For compatibility with existing FoxPro version 2.0 applications, FoxPro for Windows displays the MS-DOS style status bar when you issue the command SET STATUS ON.

Question 7

In FoxPro for Windows, when I issue the command SET DISPLAY TO VGA50 and then issue the command SET DISPLAY TO VGA25 to restore the previous setting, the status bar disappears. How do I restore the status bar?

Answer 7

Issue the SET STATUS BAR ON command.

Question 8

Why has the menu for FoxPro for Windows changed? Is the MS-DOS version of the menu available?

Answer 8

The menu in FoxPro for Windows has been modified for consistency with the standard Windows interface. The System menu on the FoxPro version 2.0 menu bar has been removed and a number of specific menu items have been moved.

Take a moment to explore the new menu structure. Note that a brief message describing each menu item is displayed in the status bar at the bottom of the main FoxPro window.

If you are more comfortable with the menu bar layout of FoxPro version 2.0, you can run a distributed FoxPro menu program that recreates it. Generate the menu first, and then execute the DOS.MPR file located in the GOODIES subdirectory with the DO command. Running this menu program replaces the FoxPro for Windows menu bar layout with the FoxPro for MS-DOS menu bar layout while retaining the Text menu for multiple font support.

To automatically display the FoxPro for MS-DOS menu bar when you load FoxPro for Windows, place the following item in the CONFIG.FPW file to execute the DOS.MPR program:

   COMMAND = DO C:\FPW26\GOODIES\DOS\DOS.MPR

Modify the path specification for DOS.MPR based on your specific installation.

Question 9

The Edit menu contains a number of new options such as Paste Special... and Change Link... . How do I use these options?

Answer 9

The new Edit menu options support Object Linking and Embedding (OLE). The items include Paste Special, Insert Object, Object, Change Link, and Convert to Static. For a detailed discussion of OLE consult the FoxPro documentation.

Question 10

The Program menu contains the new option, Beautify. What does it do?

Answer 10

The Beautify option alters the appearance of program files so they are easier to read. For example, you can choose to alter the case of key words and variables and to add indentation within procedures and DO CASE statements. You can also highlight program organization by bracketing specific control statements such as:

   IF
      DO something
   ELSE
      DO something
   ENDIF

Question 11

The Text menu is completely new. What new features does this menu offer?

Answer 11

The Text Menu adds support for multiple fonts and text formatting. The Font option makes all of your installed Windows fonts available within FoxPro. A Font option is also available in the Browse menu for Browse windows.

To change the main FoxPro window font, hold down the SHIFT key when you choose the Text menu pad. Then choose the Screen Font... option.

The Enlarge Font and Reduce Font options change all text to the next available point size in the current font. To alter the spacing of the text, select the Single Space, 1 1/2 Space, or Double Space option.

The Indent option indents the selected group of lines one tab stop. Undent does the opposite by moving a selected group of lines out one tab stop.

Question 12

Occasionally the Object menu is available. When does it display and why?

Answer 12

The Object menu is available when either the Screen Builder or the Report Writer window is open. As with the Text and Browse menus, the Object menu provides access to fonts. Specific items on the Object menu are enabled and disabled based on the currently selected object.

For example, a rectangle drawn in the Screen Design window may have an outline or pen color, a background or fill color, and a fill pattern.

Question 13

FoxPro for Windows includes Windows-style help. Is there any way to access the .DBF-style help I used in Fox version 2.0?

Answer 13

By default, FoxPro for Windows uses Windows-style help. To access the .DBF-style help, issue this command:

   SET HELP TO FOXHELP.DBF

Pressing the F1 key or choosing Contents from the menu will then open .DBF-style help.

To return to the Windows-style help, issue this command:

   SET HELP TO FOXHELP.HLP

To change the default help to the .DBF-style help, add the following statement to your CONFIG.FPW file:

   HELP = FOXHELP.DBF

Question 14

Shouldn't a full path rather than just the drive letter display when I issue the following command in the Command window?

   ? SET("DEFAULT")

Answer 14

No. This is consistent with FoxPro version 2.0 for MS-DOS. Use CURDIR() to display the path for the current directory.

Part 3: Report Writer

Overview of Questions

  1. Should I convert all of my FoxPro version 2.0 reports to FoxPro for Windows format?

  2. I used the Quick Report option to create my initial report. Now I want to add another field. In FoxPro for MS-DOS, the Report menu popup contained an option called Field... that allowed me to add a single field. What do I do in FoxPro for Windows?

  3. I have included a memo-type field in my report but only the first line prints. How can I fix this?

  4. When I place a "stretched" memo field in the detail band, I find that the fields displayed below the memo field are overwritten by some of the longer memo fields. How do I avoid this?

  5. I have placed boxes around several fields in my report. One of these fields is a memo field. How do I make the box stretch to fit the memo field?

  6. When I attempt to move a text object to a specific location in the Report Design window, the field keeps aligning itself with the nearest grid line. Why is this happening?

  7. How do I design and print multi-column reports in FoxPro version 2.6 for Windows?

  8. When I enlarge the font of objects in my report and print it, some of the information in the fields is obscured. How can I fix this?

Question 1

Should I convert all of my FoxPro version 2.0 reports to FoxPro for Windows format?

Answer 1

You may not need to. Your existing character reports will run, preview, and print unchanged in FoxPro for Windows. The engine for printing character reports is included in FoxPro for Windows. If you want to include graphical elements such as fonts and pictures in a report, then you can convert the reports to FoxPro for Windows format, or create new graphical reports from scratch.

Question 2

I used the Quick Report option to create my initial report. Now I want to add another field. In FoxPro for MS-DOS, the Report menu contained an option called Field... that allowed me to add a single field. What do I do in FoxPro for Windows?

Answer 2

You can add new fields by using the field tool located in the toolbox on the left side of the Report Design window. See the FoxPro for Windows User's Guide for additional information on the Report Writer toolbox.

Question 3

I have included a memo-type field in my report but only the first line prints. How can I fix this?

Answer 3

To display the entire contents of the memo field, you must make the field stretch vertically to fit its contents. Double-click the report field and select the Top - Field Can Stretch option from the Position Relative To item. This field will now enlarge depending on the length of the memo field contents. Select the Page Preview option to view the result.

Question 4

When I place a "stretched" memo field in the detail band, I find that the fields that display below the memo field are overwritten by some of the longer memo fields. How do I avoid this?

Answer 4

Fields or objects positioned below the memo field are still being displayed in a fixed position even though the memo field is now stretchable. To avoid being overwritten, all objects below the memo field should be positioned relative to the bottom of the Detail band. To accomplish this, double-click each of the fields and select the Bottom option from the Position Relative To item. Select the Page Preview option to view the result. If your report contains side-by-side memo fields, fields with the Bottom option specified will display below the longer of the two memo fields.

NOTE: The previous procedure applies to non-stretching fields and other objects, such as lines and text. If you have stretching fields placed below other stretching fields, you don't want to position them "relative to bottom." Stretching fields automatically float below other stretching fields.

Question 5

I have placed boxes around several fields in my report. One of these fields is a memo field. How do I make the box stretch to fit the memo field?

Answer 5

Double-click the box and select the Stretch With Band option from the Position Relative To item. Rectangles (boxes) and vertical lines can optionally stretch according to the length of the Detail band.

NOTE: You won't be able to place a stretching box around a field if the field won't be positioned relative to the top or the bottom of the band. Boxes must be positioned relative to the top or bottom of the band.

Question 6

When I attempt to move a text object to a specific location in the Report Design window, the field keeps aligning itself with the nearest grid line. Why is this happening?

Answer 6

By default, objects are automatically aligned to the nearest invisible grid lines within the Report Design window. This feature is called Snap to Grid and may be disabled by deselecting the Snap to Grid option from the Report menu.

Question 7

How do I design and print multi-column reports in FoxPro version 2.6 for Windows?

Answer 7

Select Page Layout... from the Report menu option and use the Columns spinner to select the number of columns. Clicking the up arrow increases the counter value, and clicking the down arrow decreases the counter value. The size of the Report Design window reflects the new column width, and you may need to modify existing field positions.

HINT: When creating a new report that will have columns, set the layout before you add any fields.

Question 8

When I enlarge the font of objects in my report and print the report, some of the information in the fields is obscured. How can I fix this?

Answer 8

You may need to stretch the detail lines or the objects themselves to accommodate the larger font.

Part 4: Screen Builder

Overview of Questions

  1. I don't own a mouse. How can I create a screen using the keyboard?

  2. The Field dialog in the Screen Design window allows me to create only an input field or an output field. What happened to the Edit field option in the field dialog?

  3. When I select the push button tool in the Screen Design window I have a choice of three button types: Normal, Invisible, and Picture. Were these types available in FoxPro version 2.0?

  4. I know how to click and drag objects within the Screen Design window using the Selection pointer tool. Is there an easy way to move objects a small distance?

  5. I created a screen for my application to display a number of fields. After creating the application, when I move the cursor from one field to the next, the order in which the cursor moves to the fields isn't what I expect based on the physical arrangement of the fields. How can I change the field access order without changing the physical position of the fields?

  6. When generating screens in FoxPro version 2.0, I was able to specify exactly what code to generate. Options included adding code to open and close files, to define and release windows, and to create modal screens. Is this option still available?

  7. The Color option is no longer on the Screen menu. How do I specify colors for my screen objects?

  8. When I use an @... SAY statement to display the contents of a general field, nothing appears. What am I doing wrong?

  9. I used the picture tool to add a picture field to my screen and specified the appropriate .BMP file. Please explain in more detail how the options in the area called If Picture and Frame Different Size affect the display of the picture. The options are Clip Picture, Scale Picture - Retain Shape and Scale Picture - Fill the Frame.

  10. I want to create a screen that allows online editing, while a READ is

        active, of OLE objects stored in a general field. When I add a picture
        to my screen using the picture tool, I'm not able to edit the displayed
        .BMP file. Is there a way to do this?
    

  11. Why can't I type as many characters into an input field as it appears

        will fit?
    

  12. How do I control the length of a memory variable independent of the

        size of an input field defined with @ ... GET ... SIZE?
    

  13. How can I be sure that a font I choose will be available at the client

        site?
    

  14. How do I coordinate Browse Windows with Screens?

  15. Are the Keyboard Shortcuts for FoxPro for Windows screen builder

        documented?
    

  16. I developed a screen in 1024x768 resolution and it does not appear

        consistent with lower resolutions such as 640x480. How can I develop a
        screen that will run on multiple resolutions?
    

Question 1

I don't own a mouse. How can I create a screen using the keyboard?

Answer 1

A mouse is required to create a screen with the Screen Builder.

Question 2

The Field dialog in the Screen Design window allows me to create only an input field or an output field. What happened to the Edit field option in the field dialog?

Answer 2

The Edit field option is now part of the new Edit Region dialog. To create an edit field, click the edit region tool located on the left side of the Screen Design window. Notice that as you select the tool a brief description appears in the status bar at the bottom of the screen. In the Edit Region dialog the options Select on Entry and Initially Disable Edit Region are new. For additional information on these options, see the Edit Region Dialog topic in Help.

Question 3

When I select the push button tool in the Screen Design window, I have a choice of three button types: Normal, Invisible, and Picture. Were these types available in FoxPro version 2.0?

Answer 3

FoxPro for Windows has consolidated the Invisible Button and Push Button options into a single dialog. The Picture type push button is new. You can create a picture push button using a bitmap (.BMP) picture file to depict graphically the action the push button represents. You can also use picture files with radio buttons and check boxes in FoxPro for Windows.

Question 4

I know how to click and drag objects within the Screen Design window using the Selection pointer tool. Is there an easy way to move objects a small distance?

Answer 4

Yes. Select the object to move using the Selection pointer tool and use the arrow keys to move the object one pixel at a time.

Question 5

I created a screen for my application to display a number of fields. After creating the application, when I move the cursor from one field to the next, the order in which the cursor moves to the fields isn't what I expect based on the physical arrangement of the fields. How can I change the field access order without changing the physical position of the fields?

Answer 5

Return to your original screen in the Screen Design window. From the Screen menu, select the Object Order... option. This option opens the Object Order dialog, where screen objects are listed according to their keyboard access order. To change the access order for the objects, click the button to the left of the object and drag the object to its new keyboard access position. Then rebuild your application to include the new field access order.

Question 6

When generating screens in FoxPro version 2.0, I was able to specify what code to generate. Options included adding code to open and close files, to define and release windows, and to create modal screens. Is this option still available?

Answer 6

Yes. The Generate Screen dialog contains a More button. Choose this button to view the generate code options.

Question 7

The Color option is no longer on the Screen menu. How do I specify colors for my screen objects?

Answer 7

To specify colors, first select the object or a group of objects. To modify the background color of the object select Fill Color from the Object menu. To modify the outline and text of an object, select Pen Color from the Object menu.

The AUTOMATIC setting will match the Windows color sets.

To change the background of the entire screen, choose Layout... from the Screen menu and click the Color option. You may choose a specific color or select a wallpaper pattern by clicking Wallpaper and specifying a specific .BMP file.

Question 8

When I use an @... SAY statement to display the contents of a general field, nothing appears. What am I doing wrong?

Answer 8

Use the Picture tool to display the contents of a general field. The Field tool can't display a picture.

Question 9

I used the Picture tool to add a picture field to my screen and specified the appropriate .BMP file. Please explain in more detail how the options in the area called If Picture and Frame Different Size affect the display of the picture. The options are Clip Picture, Scale Picture - Retain Shape and Scale Picture - Fill the Frame.

Answer 9

The following options apply only when the picture and frame are of a different size.

Choose Clip Picture if you want to retain the original dimensions of the picture. If the picture is larger than the frame only a portion of the image is displayed beginning with the top-left portion of the picture. Any portion of the picture that extends beyond the frame is hidden.

Choose Scale Picture - Retain Shape if you want to retain the overall shape of the picture but fill as much of the frame as possible. The picture is protected from vertical or horizontal distortion.

Choose Scale Picture - Fill the Frame if you want to fill the frame completely. The picture is horizontally or vertically distorted as needed to fill the frame.

Question 10

I want to create a screen that allows online editing, while a READ is active, of OLE objects stored in a general field. When I add a picture to my screen using the picture tool, I'm not able to edit the displayed .BMP file. Is there a way to do this?

Answer 10

Use the Field tool in the Screen Design window to create a general field in your screen. Select the WHEN clause and enter the command MODIFY GENERAL <field name> in the code snippet area. Save the screen and generate your screen and/or application. Now you will be able to edit the bitmap within the screen when the application is running.

Question 11

Why can't I type as many characters into an input field as it appears will fit?

Answer 11

In a proportional font, each character is given as much horizontal space as it needs and no more. For example, a lowercase "f" requires much less space than an uppercase "W." When an input field displays in a screen, FoxPro calculates the display width of the field by multiplying the number of characters in the table field structure by the average size of a character in the specified font. If the field is filled with characters that are wider than average, the characters don't all fit within the display width of the input field and so the characters scroll. If the field is filled with characters that are narrower than average, the characters don't fill the display width of the input field.

Question 12

How do I control the length of a memory variable independent of the size of an input field defined with @ ... GET ... SIZE?

Answer 12

Use a picture clause to control the memory variable's length, and an @ ... GET ... SIZE clause to control the width of the input field.

Question 13

How can I be sure that a font I choose will be available at the client site?

Answer 13

The safest way is to look in your WIN.INI file for fonts that have the words "All res" on the line. These are standard Windows fonts and consequently are those most likely to be available at a client site.

Question 14

How do I coordinate Browse Windows with Screens?

Answer 14

Page D2-96 of the FoxPro for Windows "Developer's Guide"

 and page D2-90 of the FoxPro for MS-DOS "Developers
Guide" give samples for coordinating Browse windows with screens but omits the SAVE clause in the example. If the optional BROWSE parameter SAVE is omitted, the Browse window will close as soon as any other object is clicked.

The code example should be changed to read as follows:

   IF NOT WVISIBLE("Client List")
      BROWSE NORMAL NOWAIT NODELETE LAST;
         TITLE "Client List" ;
         NOAPPEND NOMENU SAVE FIELDS company ;
         WHEN showgets()
   ENDIF

   IF NOT WVISIBLE("Account Details")
      SELECT details
         BROWSE NORMAL NOWAIT NODELETE LAST;
            TITLE "Client List" ;
            NOAPPEND NOMENU SAVE  ;
            FIELDS ;
            Trans_type:10, ;
            Trans_date:10, ;
            Amt:7,Service
      SELECT clients
   ENDIF

Question 15

Are the Keyboard Shortcuts for FoxPro for Windows screen builder documented?

Answer 15

FoxPro for Windows requires a mouse. MS-DOS users who are used to using the keyboard for creating screens are often confused by the lack of keyboard support in the Screen Builder. In a graphical environment such as Windows, the mouse provides a more effective means of locating and/or moving objects than the keyboard does.

To complete the transition from designing with the keyboard to designing with the mouse, icons have been added for every tool in the Screen Builder. These icons take the place of the menu shortcuts that exist in FoxPro for MS-DOS.

Question 16

I developed a screen in 1024x768 resolution and it does not appear consistent with lower resolutions such as 640x480. How can I develop a screen that will run on multiple resolutions?

Answer 16

Here are a few things to keep in mind:

  1. Develop the application using the lowest resolution that the
application will be run on. If this is 640x480, then that is the resolution you should develop the application in. Maintaining a separate screen set for each resolution is definitely an option as well. You can use SYSMETRIC(1) and SYSMETRIC(2) to determine the resolution, and then do something like the following:

     DO CASE
     CASE m.resolution = HiRes
       SET PATH TO scrns1
     CASE m.resolution = MedRes
       SET PATH to scrns2
     ...

This is particularly easy to implement if you follow the procedure of placing your screen functions in a separate program.

  1. Try not to use a screen font like MS Sans Serif. Instead, use
True Type fonts, and set the FoxPro screen font to the 'base' development font of the application. For example, if your application font is Arial 11, you would issue a this command in the initial setup code of the application:

     MODIFY WINDOW SCREEN FONT 'Arial',11

Using True Type font ensures better scaling between platforms. Keep in mind that True Type Fonts are not available in Windows 3.0.

  1. Follow general Windows interface design guidelines, such as
leaving plenty of space around objects, and not placing objects too close to the edge of a window.

Part 5: Printer Driver Questions

Overview of Questions

1 How do I use @ ... SAY Commands and Control Codes

    to Print in FP/W.

2 How can I edit an existing MS-DOS style printer driver
    or create a new one.

3 How can I invoke the Windows Printer Driver Setup Dialog
     from a program.

4 How do I access DOS printer drivers in FoxPro Windows?

Question 1

How do I use @ ... SAY Commands and Control Codes to Print in FP/W.

Answer 1

FoxPro for Windows cannot send control codes directly to a printer using a Windows printer driver. There are two techniques to work around this:

  • Open the printer in "raw mode," bypassing the Windows printer driver and communicating directly with the printer.

    -or-

  • Write all output to a text file, then copy the text file to a printer port.

Writing FoxPro for Windows programs that send control codes directly to a printer is not normally recommended. Only use these techniques when adapting existing FoxPro for MS-DOS code that sends control codes to the printer.

The following examples send control codes to switch an Epson FX-80 dot-matrix printer's compressed mode on and off.

NOTE: When using these techniques, do not use any of the ? or ?? commands for output. Only use @ ... SAY commands.

Technique 1: Open the Printer in Raw Mode

There are two ways to open the printer in raw mode:

  • Use the ??? " " command.

    -or-

  • Use the SET PDSETUP TO <driver name> command.

Use the ??? " " Command:

Issue SET DEVICE TO PRINT and SET PRINTER TO commands to turn off all open print commands.

Issue a ??? " " command to open the printer in raw mode.

Issue @ ... SAY commands to send control codes and text to the printer.

After printing, issue a SET PRINTER TO command to flush the print buffer and return control to the Windows printer driver.

The following code demonstrates these steps:

   SET DEVICE TO PRINT
   SET PRINTER TO
   ??? " "
   @ 1,0 SAY 'NORMAL TEXT'
   @ 2,0 SAY CHR(15) && Control code to turn compressed mode on
   @ 2,0 SAY 'CONDENSED text?'
   @ 3,0 SAY CHR(18) && Control code to turn compressed mode off
   @ 3,0 SAY 'NORMAL again'
   SET DEVICE TO SCREEN
   SET PRINTER TO

NOTE: In some circumstances, the last @ ... SAY command may not print. If this problem occurs, add an additional @ ... SAY command that prints a blank line (so that the lost line is just a blank).

Use the SET PDSETUP TO <Driver Name> Command:

Issue a SET PRINTER TO command to clear the print buffer of all open print commands.

Issue a SET PDSETUP TO <driver name> command to open the printer in raw mode. You MUST already have an existing FoxPro 2.0 or 2.6 for MS-DOS printer driver in the current resource file.

NOTE: The important property of this command is that setting a FoxPro for MS-DOS printer driver opens the printer in raw mode. The printer driver itself is not used to control printing (that is done though control codes). In fact, any FoxPro for MS-DOS printer driver can be used.

Issue a SET DEVICE TO PRINTER command to direct the @ ... SAY commands to the printer.

Issue @ ... SAY commands to send control codes and text to the printer.

After printing, issue a SET DEVICE TO SCREEN command to redirect the output to the screen.

Issue a SET PRINTER TO command to flush the print buffer and return control to the Windows printer driver.

The following code demonstrates these steps:

   SET PRINTER TO
   SET PDSETUP TO "Epson"
   SET DEVICE TO PRINT

   @ 1, 0 SAY 'NORMAL text'
   @ 2, 0 SAY  CHR(15) && Control code to turn compressed mode on
   @ 2, 0 SAY  'CONDENSED text'
   @ 3, 0 SAY  CHR(18) && Control code to turn compressed mode on
   @ 3, 0 SAY 'normal again'

   SET DEVICE TO SCREEN
   SET PRINT TO

Technique 2: Write to Text File and Copy to Printer Port

Issue a SET DEVICE TO FILE <filename> command to direct output to a file.

Issue @ ... SAY commands to send control codes or text to the printer.

Issue a SET DEVICE TO SCREEN command to redirect output to the screen.

Issue a SET SAFETY OFF command so FoxPro for Windows does not confirm copying the output file to the printer port (which it believes to be a file).

Issue a COPY FILE <filename> TO <printer port>.DOS command to copy the output file to the printer port.

Issue a SET SAFETY ON command to turn safety on again.

The following code demonstrates these steps:

   SET DEVICE TO FILE output.prn

   @ 1,0 SAY 'NORMAL text'
   @ 2,0 SAY CHR(15) && Control code to turn compressed mode on
   @ 2,0 SAY 'CONDENSED text'
   @ 3, 0 SAY CHR(18) && Control code to turn compressed mode off
   @ 3, 0 SAY 'Back to normal text'

   SET DEVICE TO SCREEN
   SET SAFETY OFF
   COPY FILE output.prn TO lpt1.dos
   SET SAFETY ON

When Windows prints to a file named LPT1.DOS, MS-DOS interprets the request to open the file LPT1.DOS as a request to send data to the printer port, and it sends the data out through its own printing handler. Because Windows thinks that LPT1.DOS is an MS-DOS file, the Print Manager is not used.

Question 2

How can I edit an existing MS-DOS style printer driver or create a new one.

Answer 2

In FoxPro for Windows, the SET PDSETUP TO <driver_name> command selects only an existing MS-DOS style printer driver. It cannot edit an existing MS-DOS style printer driver or create a new one.

To use the SET PDSETUP TO <driver_name> command in FoxPro for Windows, the current resource file (by default FOXUSER.DBF and its associated memo file, FOXUSER.FPT) must already have an MS-DOS style printer driver loaded. This MS-DOS style printer driver must have been previously created by FoxPro for MS-DOS.

FoxPro for Windows normally uses Windows printer drivers for all its printing. Windows printer drivers are changed through the Windows Control Panel.

Only use the SET PDSETUP TO <driver_name> command with character-based reports that were created in FoxPro for MS-DOS.

NOTE: The SET PDSETUP <driver_name> command has no effect on Windows printer drivers.

Question 3

How can I invoke the Windows Printer Driver Setup Dialog from a program.

Answer 3

There are two methods to invoke the Windows Printer Driver Setup Dialog.

The first method is to use the new function SYS(1037)

The second method is to use a RUN command. The following example illustrates this:

  RUN /N control printers

NOTE: These commands will not work with Windows version 3.0. For example, the RUN /N CONTROL.EXE PRINTERS command will only run the Control Panel; it will not open the Printers dialog box.

Question 4

How do I access DOS printer drivers in FoxPro Windows?

Answer 4

In FoxPro for Windows, the SET PDSETUP TO <driver_name> command selects only an existing MS-DOS style printer driver. It cannot edit an existing MS-DOS style printer driver or create a new one.

To use the SET PDSETUP TO <driver_name> command in FoxPro for Windows, the current resource file (by default FOXUSER.DBF and its associated memo file, FOXUSER.FPT) must already have an MS-DOS style printer driver loaded. This MS-DOS style printer driver must have been previously created by FoxPro for MS-DOS.

FoxPro for Windows normally uses Windows printer drivers for all its printing.

Only use the SET PDSETUP TO <driver_name> command with character-based reports that were created in FoxPro for MS-DOS.

NOTE: The SET PDSETUP <driver_name> command has no effect on Windows printer drivers.

                 ================
                 End of PSSQA.TXT
                 ================


Additional reference words: FoxWin 2.60a tips Q&A ideas contents
subdirectory
KBCategory: kbreadme kbref
KBSubcategory: FxinteropOle


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.