Skip to main content

Problem:

This program demonstrates how to allow a user to select a font and style for printing using the Windows SDK function ChooseFont in conjunction with the Net Express PC_PRINTER routines.

Resolution:

INTRODUCTION

==========

This program will demonstrate how to allow a user to select a font and style for printing using the Windows SDK function ChooseFont in conjunction with the Net Express PC_PRINTER routines.

This function allows you to present a list of available fonts to the user for selection. This can also be done by setting the appropriate printer-flag when using the PC_PRINTER_OPEN call but the ChooseFont function is more powerful. It allows you to present a list of fonts based on certain criteria such as only Truetype, only fixed fonts etc.

The criteria flags can be found in the CFDEFINE.CPY copy file.

This example will use the selected font to output various text lines to the printer. The lines will be printed in differing point sizes and text attributes such as bold and italics etc., if they are available for the selected font.

SOURCE FILES:

=========

Program Files         Description

-------------------     -----------------------------------------------------------

PRNTFONT.CBL     Source program that makes a call to PC_PRINTER_OPEN and

                              PC_PRINTER_INFO in order to get information to pass to the Windows SDK

                              function ChooseFont. It will display a printer setup dialog box allowing the user

                              to select a printer to use.

CFDEFINE.CPY      Copy file containing the converted constants used in the ChooseFontA

                              Windows SDK function.

CHOOSEFONT.CPY     Copy file containing the working-storage data items referenced by the

                              ChooseFontA Windows SDK function.

LOGFONT.CPY       Copy file containing the working-storage data items referenced by the

                              ChooseFontA Windows SDK function.Contains information describing the

                              characteristics of the desired font.

PRNTOPEN.CPY     Copy file containing the working-storage data items referenced by the

                              PC_PRINTER_OPEN call-by-name routine.

PRNTINFO.CPY     Copy file containing the working-storage data items referenced by the

                              PC_PRINTER_INFO call-by-name routine.

REQUIREMENTS:

==========

This sample should run in all environments. At least one printer should be attached to or be accessible from the system on which this program is run.

OPERATION:

========

Rebuild this project to create the file prntfont.exe. This is a character mode program that will display its progress to an application output window. It will print several pages of output text to a selected printer.

NOTE:

====

This program and any program using the ChooseFont function call must be linked to the import library COMDLG32.LIB. This can be found in the Net Express\\base\\lib directory.

==========================================================

Keywords: demonstration, sample, example, demo, prntfont.zip

demo.ex

demo.me

demo.ne

Attachments:

prntfont.zip

Old KB# 4060