gleichman Posted January 9, 2006 Report Share Posted January 9, 2006 I would like to send my reports to a printer selected through the Windows print setup dialog. In my search, I found "Set Default Printer.vi". The problem I have with this VI (besides the fact that it is locked) is that it does not return an error or any other notification if the "Cancel" button is selected on the dialog. Anybody know who wrote this VI or have a better suggestion for how to do this? Alan Quote Link to comment
Rolf Kalbermatter Posted January 9, 2006 Report Share Posted January 9, 2006 I would like to send my reports to a printer selected through the Windows print setup dialog. In my search, I found "Set Default Printer.vi". The problem I have with this VI (besides the fact that it is locked) is that it does not return an error or any other notification if the "Cancel" button is selected on the dialog.Anybody know who wrote this VI or have a better suggestion for how to do this? This is my hacked together variant of the Set Default Printer.vi. I did some empirical research activity (in earlier days this was called reverse engineering and a hex editor and some disassembly can help wonders here) and this is to the best of my knowledge what the NI VI does, with some extra code to fix the behavior of that function with invalid inputs. BTW: There seems no way to get the cancel status at all. (Basically calling this function with an empty string and FALSE for show dialog, sets the internal LabVIEW printer name apparently to an invalid setting and after that any print activity will abort with a printer dialog error (34) and the only way to get printing back to work is to restart LabVIEW or the applciation). You can produce the same error with the Application property in LabVIEW >= 7.x Printer.Default Printer). I posted a bug report about this but never received anything besides the automatic acknowledgment until now. Rolf Kalbermatter Download File:post-349-1136843760.vi Quote Link to comment
gleichman Posted January 10, 2006 Author Report Share Posted January 10, 2006 This is my hacked together variant of the Set Default Printer.vi. I did some empirical research activity (in earlier days this was called reverse engineering and a hex editor and some disassembly can help wonders here) and this is to the best of my knowledge what the NI VI does, with some extra code to fix the behavior of that function with invalid inputs. That's illeagal here in the land of freedom. There seems no way to get the cancel status at all. Unfortunately, that's the functionality I was looking for. Reports showing up at the printer after selecting cancel is hard to explain to users. I have a very crude and not 100% work around. I check the mouse position immediately after the call. If the user has not moved the window, I know if cancel has been pushed. Of course, if the window has been moved all bets are off. Because the Print Setup window is a Dialog, I don't know anyway of tracking its position. Alan Quote Link to comment
i2dx Posted January 11, 2006 Report Share Posted January 11, 2006 i had a similar problem some time ago and my solution was, to programm the select printer dialog myself. You can get the list of installed printers like this: Download File:post-885-1136969315.zip Quote Link to comment
Rolf Kalbermatter Posted January 12, 2006 Report Share Posted January 12, 2006 i had a similar problem some time ago and my solution was, to programm the select printer dialog myself. You can get the list of installed printers like this: I was considering this approach as well. But the problem is that it does only allow to select the printer itself and not any of the print properties for the particular printer such as paper selection etc. I'll have to look into the possiblities. Rolf Kalbermatter That's illeagal here in the land of freedom. Well, at least until now, not so here Rolf Kalbermatter Quote Link to comment
yonatan.tidhar Posted January 12, 2006 Report Share Posted January 12, 2006 I was considering this approach as well. But the problem is that it does only allow to select the printer itself and not any of the print properties for the particular printer such as paper selection etc. I'll have to look into the possiblities.Rolf Kalbermatter Well, at least until now, not so here Rolf Kalbermatter what abaut this example from ni site? http://sine.ni.com/apps/we/niepd_web_displ...034080020E74861 Download File:post-2756-1137065441.vi Quote Link to comment
Rolf Kalbermatter Posted January 12, 2006 Report Share Posted January 12, 2006 what abaut this example from ni site?http://sine.ni.com/apps/we/niepd_web_displ...034080020E74861 The problem with that VI is that it prints the panel as documentation, that is with a header. To create reports for instance it is usually not desirable to have any other information on the printout than what is on the actual panel that is to be printed. This printout of panels without any additional information works very fine if you set the VI properties to "print when completed". But you have to create your own custom print dialog because the one discussed earlier will not indicate a user cancel. Rolf Kalbermatter Quote Link to comment
i2dx Posted January 12, 2006 Report Share Posted January 12, 2006 I was considering this approach as well. But the problem is that it does only allow to select the printer itself and not any of the print properties for the particular printer such as paper selection etc. I'll have to look into the possiblities.Rolf Kalbermatter i have not checked this, yet, but i guess, you can open the properties via ActiveX, when you have the printer name. Ok, you need an extra button in your dialog, but i think this can work?! Quote Link to comment
gleichman Posted January 12, 2006 Author Report Share Posted January 12, 2006 The problem with that VI is that it prints the panel as documentation, that is with a header. To create reports for instance it is usually not desirable to have any other information on the printout than what is on the actual panel that is to be printed.This printout of panels without any additional information works very fine if you set the VI properties to "print when completed". But you have to create your own custom print dialog because the one discussed earlier will not indicate a user cancel. Rolf Kalbermatter This brings up an interesting option. I'm not using VI panels to create reports. I'm using MS-Excel with the report generation toolkit. Could I call the print dialog through Excel? I've done some digging, but I haven't found anything yet. The interesting thing about the VI that Yonatan suggested is that it returns an error on Cancel! I feel like I'm working with VB again (many solutions that almost work). Alan Quote Link to comment
malef Posted April 7, 2006 Report Share Posted April 7, 2006 Rolf, your PRINT_Set_Default_Printer.vi works fine with LV version > 7.1. Thank you. I tried to rebuild it for a LV 5.1.1 application on the same machine. Error list shows up Quote Link to comment
didierj Posted April 10, 2006 Report Share Posted April 10, 2006 I tried to rebuild it for a LV 5.1.1 application on the same machine. Error list shows up Quote Link to comment
Rolf Kalbermatter Posted April 10, 2006 Report Share Posted April 10, 2006 Rolf,your PRINT_Set_Default_Printer.vi works fine with LV version > 7.1. Thank you. I tried to rebuild it for a LV 5.1.1 application on the same machine. Error list shows up Quote Link to comment
malef Posted April 10, 2006 Report Share Posted April 10, 2006 ...... But one drawback is that LabVIEW and only that is used as special keyword in the Call Library Node to mean the current LabVIEW instance which for build applications will be not labview.exe.Rolf Kalbermatter Didier and Rolf, many thanx for your replies. :worship: Setting the CLF path to ...\LabVIEW.exe and the function name to SetDefaultPrinter works in development environment of LV 5.1, but does not work in a built application as Rolf stated already. Behind the magic of SetDefaultPrinter CLF there should be a winapi call? As my coworker needs this functionalty in this really old LV version he will solve it. Never the less any more hints appreciated Manfred Download File:post-831-1144670212.vi Quote Link to comment
Rolf Kalbermatter Posted April 11, 2006 Report Share Posted April 11, 2006 Didier and Rolf,many thanx for your replies. :worship: Setting the CLF path to ...\LabVIEW.exe and the function name to SetDefaultPrinter works in development environment of LV 5.1, but does not work in a built application as Rolf stated already. Behind the magic of SetDefaultPrinter CLF there should be a winapi call? As my coworker needs this functionalty in this really old LV version he will solve it. Never the less any more hints appreciated Manfred Download File:post-831-1144670212.vi Just try "LabVIEW" as library name. It might work in the built application but there is no guarantee. The special LabVIEW library name was introduced in probably around 5.0. Not sure if LabVIEW was already using it as a place holder for the current instance or if that was only added later on. There is probably quite a lot more than a single Windows API call behind SetDefaultPrinter. Printing in LabVIEW is somewhat involved and the original idea was to hide as much as possible of the printer setup and configuration from the user. This makes it now a little difficult to provide full print control. And the reason this name was changed in later versions is probably because it had a name clash on one of the platforms LabVIEW is compiled for. Rolf Kalbermatter Quote Link to comment
Donald Posted April 12, 2006 Report Share Posted April 12, 2006 Does anybody knows if these VIs also work for LV7+ linux these days? I tried the above used property nodes under LV7/Suse7.2 and the only thing that was returned as a printer was *??? Quote Link to comment
Norm Nelson Posted November 2, 2006 Report Share Posted November 2, 2006 I'm working with LabView 6.1 and have several vi's that display data I've taken. I need to be able to print to differnet printers. Using some of the above code I can change the defalt printer. Unfortunatly that doesn't change the printer under the File -> Page Setup -> Printer Setup .... No matter what printer I select it changes the default printer highlight in the windows printers and faxes window but the Labview print panel.vi always prints to the same printer unles I manually go in to the File -> Page Setup -> Printer Setup .... and change it there. What am I missing? Thanx, Norm Quote Link to comment
thomas2609 Posted January 22, 2008 Report Share Posted January 22, 2008 maby someone needs my vi to get the default printer name . Quote Link to comment
Cookie Posted February 15, 2008 Report Share Posted February 15, 2008 I'm having the same issue. I want to change the printer to a pdf driver (to save the front panel as a .pdf) then back to the default printer to print the results as a hard copy immediately after. This works only if I change the printer, close labview and restart my application then it will recognize the change? I think this may be a bug, because I see in 8.5 this is a bug fix. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.