eric K.
eric K.

Reputation: 43

C# Winform PrintDialog Pages popup

in C# Winform, i'm sending an Image to the printer using the PrintDialog... using this code:

       private void PrintSnippedImage()
    {
        PrintDocument pDoc = new PrintDocument();
        pDoc.PrintPage += PrintPage;

        PrintDialog pDialog = new PrintDialog();
        pDialog.ShowHelp = true;
        pDialog.AllowSelection = false;
        pDialog.AllowSomePages = false;
        pDialog.Document = pDoc;
        if (pDialog.ShowDialog() == DialogResult.OK)
        {
            pDoc.Print();
        };
    }

    private void PrintPage(object o, PrintPageEventArgs e)
    {
        System.Drawing.Image img = Glob.SnippedImage;
        Point loc = new Point(10, 10);
        e.Graphics.DrawImage(img, loc);
    }

I get a popup that shows "Printing... Page 1 of document" with a Cancel button. it appears in seemingly random locations on one of my monitors.

is there a way to inhibit this popup, or at least force it to appear on the monitor in the general location of the application that called it?

it looks like this:

popup window

Upvotes: 3

Views: 314

Answers (1)

Dave Cluderay
Dave Cluderay

Reputation: 7426

It should be a case of swapping the PrintController implementation from PrintControllerWithStatusDialog (the default) to StandardPrintController. See https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.printdocument.printcontroller?view=dotnet-plat-ext-6.0#system-drawing-printing-printdocument-printcontroller

Upvotes: 1

Related Questions