LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print Configuration Dialog Box

Hello all,
    I want to enable the print configuration dialog box pop up when a button is clicked in vi.
This is standard windows printer configuration dialog box which pops up when any file (xls,txt etc.)
is tried printing.Any suggestions please ?
Also i have attached the standard windows print dialog box, just incase.
Thanks in advance,
Nalin

0 Kudos
Message 1 of 8
(4,716 Views)

This can be done easily using ActiveX and the Microsoft Common Dialog Control 6.0 server class to call the Windows printer dialog. Follow these steps to get started:

1. Browse to the ActiveX palette in LabVIEW: All Functions >> Communications >> ActiveX.

2. Place an Automation Open VI on the block diagram. Right click the Automation Refnum input and select Create >> Constant.

3. Right click the constant and select Select ActiveX Class >> Browse. Browse to the Microsoft Common Dialog Control 6.0 v1.2 Type Library and select the object MSComDlg.ICommonDialog.

4. You can now wire the Automation Refnum from the Automation Open VI to property nodes to set various properties for the printer window, and then to an invoke node, where you can select the function Show Printer to pop up the printer dialog.

I'll attach an example .llb file that demonstrates this in practice. This example is not yet fully tested, but I ran it successfully on my machine, and it will definitely help you get started.

 

 

Jarrod S.
National Instruments
Message 2 of 8
(4,704 Views)
Jarrod,
 
The attached example only prints to the default printer.  What is the property node to retrieve the printer name from the print dialog box?  I can't seem to find it.
 
Steffan
0 Kudos
Message 3 of 8
(4,672 Views)
In general use a property node with nothing attached to it in LabVIEW with the property Printing >> Default Printer or Printing >> Avalaible Printers to return the printers configured with Windows. One of these string items can be wired into the printer input of the report generation Print Report VI to select a printer.
 
In regards to the Microsoft Common Dialog 6.0 ActiveX controls, the printer selection from the dialog seems to be determined by the hDC output, which stands for hardware device context. If you modify the demo posted above to send in the appropriate flag value, either an informational or a direct hardware device context handle is returned in the ICommon property hDC. Input the flag value 512 to the ICommonDialog property Flags to return an hardware device context handle from the hDC property, or 1024 to return an informational device context.
 
 
More information about how to extract any meaningful information from this I32 number can doubtlessly be found at msdn.com, but I'm not sure personally how to do it. Specifically, here are a few posts to start your search at:
 
Using the Print Dialog Box
 
Common DialogControl Constants

Alternatively, consider avoiding the Common Dialog Control calling a dll that will directly return the selected printer name from a dialog:
 
Hope this helps!
 
Jarrod S.
National Instruments
0 Kudos
Message 4 of 8
(4,633 Views)

Hello,

 I have problem with print dialog box. I tried the way mentioned above (ActiveX-MSComDlg.ICommonDialog), but an error occured.Does anybody know why it happened?

I tried also this way:
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DD2556A4E034080020E74861&p_...

It displays the diloag, but I don't know how to print something.
Is there other way to call print dialog?

Thank you
I'm using LW 7.1, WXP SP2

LV 2011, Win7
Download All
0 Kudos
Message 5 of 8
(4,441 Views)
When I tried to create ActiveX container error occured.
Translation is: "Class is not licenced for usising"
LV 2011, Win7
0 Kudos
Message 6 of 8
(4,437 Views)
This works well:
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E9F956A4E034080020E74861&p_node=DZ52084
LV 2011, Win7
0 Kudos
Message 7 of 8
(4,409 Views)

I want to control printer names of print dialog box. When I invoke print dialog box using .net constructor node. It is showibg me 4-5 printer options. I want it to control to 1 option only which will be default printer. Ho to control it?? 

-Devashri

0 Kudos
Message 8 of 8
(2,812 Views)