Example Code

Printer dialog box for PrintTextBuffer() and PrintTextFile() in LabWindows/CVI

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Other

Code and Documents

Attachment

Overview
Provides a printer dialog box to be used with PrintTextBuffer() and PrintTextFile(), allowing the user to select a printer.


Description
Many programs need to print various reports, some of which are generated into text buffers. The PrintControl() function brings up the printer selection box before printing, but PrintTextBuffer() and PrintTextFile() do not. The attached code provides a function that will bring up the Windows printer selection box, copy some initial parameters into it from the current LabWindows/CVI printer settings, allow the user to select the printer, and then load the results back into the active printer settings so that PrintTextBuffer() and PrintTextFile() will print to the selected printer with the selected paper orientation.

You need to have the full SDK installed to use this. For further information, look in the microsoft online documentation:

http://technet.microsoft.com/en-us/library/ms646940%28v=VS.85%29.aspx

 


Requirements

  • LabWindows/CVI (written in Version 2010)
  • Full Windows SDK


Steps to Implement or Execute Code

  1. Call the “UTIL_PrinterSelect(unsigned short nMaxPage)” function from your code.
  2. The “nMaxPage” specifies the last page in the document. Pass 0 if not known.

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.