3

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

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
eric K.
  • 43
  • 5

1 Answers1

1

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

Dave Cluderay
  • 7,268
  • 1
  • 29
  • 28
  • 1
    Excellent Mr. Cluderay... just adding this line: pDoc.PrintController = new StandardPrintController(); worked... the popup is gone. – eric K. Feb 07 '22 at 21:10