Solved

Setting a printer to Pause

Posted on 1998-09-19
6
441 Views
Last Modified: 2010-04-03
How can I set a printer to pause and restart it. I think it is with TPrinter.SetPrinter. A example of code would be great.
0
Comment
Question by:ymailhot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:ymailhot
ID: 1340280
Edited text of question
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340281
How about this.???

uses Printers;
{...}

Printer.BeginDoc;
//Do some stuff...If button is pressed then...stop

Printer.EndDoc;
//Then again...BeginDoc;

Is this gonna work>?
0
 

Author Comment

by:ymailhot
ID: 1340282
I am talking about pausing the printer. The job is already spooled to the print manager.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:ronit051397
ID: 1340283
0
 

Author Comment

by:ymailhot
ID: 1340284
Thank you ronit. This proved to be very helpful. You may have the points.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1340285
OK. Just for the others to see:

"...
Hello mates !

              Well.. at last I did it ! Let me explain !

              Well, a couple of days ago I needed a code to stop de Printer at Window NT..
              so I grab the WINAPI help file and tried to find how to do it.. After lot of
              tries nothing worked.. so I had a look at this newsgroup.. I saw that many
              people had the same problems with the SetPrinter call as me.. I mean or
              Address errors or not working... so my problem was not solved.. BUT.. what
              hapenned.. I don't know how I saw the last part of the OpenPrinter statement
              at the help file and saw that if somebody wanted to do anything altering the
              printer it has to be opened with PRINTER_ALL_ACCESS parameter at the
              PrinterDefaults struct... aha !!!... after that all worked fine... just try
              out my source.. you will see...

              I wish this code would be helpfull to anyone !

              Albert

              procedure whatever
              var
               hPrinter : THandle;
               PrinterName : PChar;
               PrinterDefaults : TPrinterDefaultsA;
               DevMode : PDeviceModeA;
               Needed : integer;
              begin
               PrinterName := PChar(Printer.Printers[Printer.PrinterIndex]);

               WinSpool.OpenPrinter(PrinterName,hPrinter,nil);

               Needed :=
              WinSpool.DocumentProperties(Handle,hPrinter,PrinterName,DevMode^,DevMode^,0)
              ;
               if Needed < 0 then
                begin
                 exit;
                end;

               GetMem(DevMode,Needed);
              WinSpool.DocumentProperties(Handle,hPrinter,PrinterName,DevMode^,DevMode^,DM
              _COPY);

               PrinterDefaults.pDatatype := nil;
               PrinterDefaults.pDevMode := @DevMode^;
               PrinterDefaults.DesiredAccess := PRINTER_ALL_ACCESS;

               ClosePrinter(hPrinter);

               if OpenPrinter(PrinterName,hPrinter,@PrinterDefaults) then
                begin
                 if WinSpool.SetPrinter(hPrinter,0,nil,PRINTER_CONTROL_PAUSE) then
                  begin
                   ClosePrinter(hPrinter);
                  end
                end;

               ClosePrinter(hPrinter);
               FreeMem(DevMode);
              end;
."

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question