I have a simple PrintDialog (code below). My application is a tray application, meaning it has no windows in it and only contains a few simple right click options from the tray icon. Given a file path, the application will open a print dialog and let the user print the item.
I am seeing the following issue...the first time the print works, the dialog pops up to the top, taking precedence over all of my other open programs. After the first, the print dialog is always opened behind everything else that I have opened. For example, I have a web browser open on my screen, the print dialog will open behind that every time after the first print.
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == DialogResult.OK)
{
ProcessStartInfo info = new ProcessStartInfo(filename);
info.Arguments = "\"" + pd.PrinterSettings.PrinterName + "\"";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.UseShellExecute = true;
info.Verb = "PrintTo";
try { Process.Start(info); }
catch (Exception e) {
// An exception occured while attempting to print
return false;
}
return true;
}