LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access the Windows Print Setup Dialog

I am using the report generation VIs to create a large form to be printed. I would like my user to have full control over which printer to use and all printer specific options, such as print quality, paper source, etc., just as they would if they were printing from any other Windows application.
0 Kudos
Message 1 of 4
(3,996 Views)
There are two example programs on the web. Goto www.ni.com >> support >> advanced search (it is at the bottom--click on the words). This lauches a new web page which is the best way to search our site for support questions. Enter print setup dialog in the all the words field, search the example programs and press go. You should have two hits.

Jeremy Braden
National Instruments
0 Kudos
Message 2 of 4
(3,996 Views)
I don't see any way in which your response is useful. The first example displays the setup window, but there is no way of putting the user's selections to use. Once they hit OK, the window goes away, and I'm left with nothing. There are no outputs from the VI except "OK". The second VI is locked, so we have no access to the block diagram, but besides that, it also appears useless. All it can do is change the default printer. It says that changing other settings may have unexpected results.
0 Kudos
Message 3 of 4
(3,996 Views)
An easy way would be to directly link to COMMDLG.DLL in the
Windows\System directory to the function:

BOOL PrintDLg(LPPRINTDLG lppd);

where LPPRINTDLG is a long pointer to the initialization structure:

PRINTDLG which is defined as:

typedef struct tagPD {
DWORD lStructSize;
HWND hwndOwner;
HANDLE hDevMode;
HANDLE hDevNames;
HDC hDC;
DWORD Flags;
WORD nFromPage;
WORD nToPage;
WORD nMaxPage;
WORD nCopies;
HINSTANCE hInstance;
DWORD lCustData;
LPPRINTHOOKPROC lpfnPrintHook;
LPSETUPHOOKPROC lpSetupTemplateName;
HANDLE hPrintTemplate;
HANDLE hSetupTemplate;
}

You could make it a bit easier by wrapping this C call up in a wrapper
DLL that is a bit easier for LabVIEW to swallow and hide things like
LPPRINTHOOKPROC from it inside the wrapper.

You could also do it with a DLL but writing MFC style C++ could and
using the CPrintDialog object. I did something similar once for a
better version of a directory picker from LabVIEW. The National
Instruments version of a directory picker is confusing and can lead
to user induced errors that you have to write elaborate code to
protect against because they basically modified a file picker instead
of using the Microsoft directory "shell" style picker which can only
pick directories that exist.

If DWORD, HANDLE, HWND, LPPRINTHOOKPROC, etc. are confusing to you
then you will need to spend some time on the Microsoft MSDN web site
and/or the local bookstore to pick up a book on Win32 programming
and/or MFC programming for Windows.

Finally if you don't like C, you could even write a Visual Basic
ActiveX DLL and call it using LabVIEW ActiveX vi's.


Douglas De Clue
LabVIEW developer /(and MSVC programmer too 🙂
ddeclue@bellsouth.net


"Terry B." wrote in message news:<5065000000050000003C840000-1023576873000@exchange.ni.com>...
> I don't see any way in which your response is useful. The first
> example displays the setup window, but there is no way of putting the
> user's selections to use. Once they hit OK, the window goes away, and
> I'm left with nothing. There are no outputs from the VI except "OK".
> The second VI is locked, so we have no access to the block diagram,
> but besides that, it also appears useless. All it can do is change
> the default printer. It says that changing other settings may have
> unexpected results.
0 Kudos
Message 4 of 4
(3,996 Views)