2002-05-02 15:50:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
/* -------------------------------------------------------------------
|
|
|
|
To Build This:
|
|
|
|
|
2014-10-25 21:25:22 +04:00
|
|
|
You need to add this to the the makefile.win in mozilla/dom/base:
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
.\$(OBJDIR)\nsFlyOwnPrintDialog.obj \
|
|
|
|
|
|
|
|
|
|
|
|
And this to the makefile.win in mozilla/content/build:
|
|
|
|
|
|
|
|
WIN_LIBS= \
|
|
|
|
winspool.lib \
|
|
|
|
comctl32.lib \
|
|
|
|
comdlg32.lib
|
|
|
|
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include "plstr.h"
|
|
|
|
#include <windows.h>
|
2003-10-08 00:39:25 +04:00
|
|
|
#include <tchar.h>
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
#include <unknwn.h>
|
|
|
|
#include <commdlg.h>
|
|
|
|
|
2018-12-13 16:17:14 +03:00
|
|
|
#include "mozilla/BackgroundHangMonitor.h"
|
2002-05-02 15:50:36 +04:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsIPrintSettings.h"
|
|
|
|
#include "nsIPrintSettingsWin.h"
|
2020-07-05 22:00:43 +03:00
|
|
|
#include "nsIPrinterList.h"
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
#include "nsRect.h"
|
|
|
|
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "prenv.h" /* for PR_GetEnv */
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winspool.h>
|
|
|
|
|
|
|
|
// For Localization
|
|
|
|
|
2003-07-19 20:29:41 +04:00
|
|
|
// For NS_CopyUnicodeToNative
|
|
|
|
#include "nsNativeCharsetUtils.h"
|
|
|
|
|
2002-05-02 15:50:36 +04:00
|
|
|
// This is for extending the dialog
|
|
|
|
#include <dlgs.h>
|
|
|
|
|
2016-04-05 09:24:28 +03:00
|
|
|
#include "nsWindowsHelpers.h"
|
2016-07-02 01:58:31 +03:00
|
|
|
#include "WinUtils.h"
|
2016-04-05 09:24:28 +03:00
|
|
|
|
2002-05-02 15:50:36 +04:00
|
|
|
//-----------------------------------------------
|
|
|
|
// Global Data
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
2013-04-03 04:27:12 +04:00
|
|
|
static HWND gParentWnd = nullptr;
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Returns a Global Moveable Memory Handle to a DevMode
|
2002-09-26 15:38:03 +04:00
|
|
|
// from the Printer by the name of aPrintName
|
|
|
|
//
|
|
|
|
// NOTE:
|
2003-07-19 20:29:41 +04:00
|
|
|
// This function assumes that aPrintName has already been converted from
|
|
|
|
// unicode
|
2002-09-26 15:38:03 +04:00
|
|
|
//
|
2016-04-05 09:24:28 +03:00
|
|
|
static nsReturnRef<nsHGLOBAL> CreateGlobalDevModeAndInit(
|
2017-08-08 09:07:55 +03:00
|
|
|
const nsString& aPrintName, nsIPrintSettings* aPS) {
|
2016-04-05 09:24:28 +03:00
|
|
|
nsHPRINTER hPrinter = nullptr;
|
2003-07-19 20:29:41 +04:00
|
|
|
// const cast kludge for silly Win32 api's
|
2013-12-03 19:09:50 +04:00
|
|
|
LPWSTR printName =
|
|
|
|
const_cast<wchar_t*>(static_cast<const wchar_t*>(aPrintName.get()));
|
2013-04-03 04:27:12 +04:00
|
|
|
BOOL status = ::OpenPrinterW(printName, &hPrinter, nullptr);
|
2016-04-05 09:24:28 +03:00
|
|
|
if (!status) {
|
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2016-04-05 09:24:28 +03:00
|
|
|
// Make sure hPrinter is closed on all paths
|
|
|
|
nsAutoPrinter autoPrinter(hPrinter);
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2016-04-05 09:24:28 +03:00
|
|
|
// Get the buffer size
|
2016-08-22 08:45:49 +03:00
|
|
|
LONG needed = ::DocumentPropertiesW(gParentWnd, hPrinter, printName, nullptr,
|
|
|
|
nullptr, 0);
|
|
|
|
if (needed < 0) {
|
2016-04-05 09:24:28 +03:00
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2016-04-08 18:37:04 +03:00
|
|
|
|
2020-09-15 18:05:52 +03:00
|
|
|
// Some drivers do not return the correct size for their DEVMODE, so we
|
|
|
|
// over-allocate to try and compensate.
|
|
|
|
// (See https://bugzilla.mozilla.org/show_bug.cgi?id=1664530#c5)
|
|
|
|
needed *= 2;
|
2016-04-05 09:24:28 +03:00
|
|
|
nsAutoDevMode newDevMode(
|
|
|
|
(LPDEVMODEW)::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, needed));
|
|
|
|
if (!newDevMode) {
|
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2016-04-08 18:37:04 +03:00
|
|
|
|
2016-08-22 08:45:49 +03:00
|
|
|
nsHGLOBAL hDevMode = ::GlobalAlloc(GHND, needed);
|
2016-04-05 09:24:28 +03:00
|
|
|
nsAutoGlobalMem globalDevMode(hDevMode);
|
|
|
|
if (!hDevMode) {
|
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2016-04-08 18:37:04 +03:00
|
|
|
|
2016-08-22 08:45:49 +03:00
|
|
|
LONG ret = ::DocumentPropertiesW(gParentWnd, hPrinter, printName, newDevMode,
|
|
|
|
nullptr, DM_OUT_BUFFER);
|
|
|
|
if (ret != IDOK) {
|
2016-04-05 09:24:28 +03:00
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2016-04-08 18:37:04 +03:00
|
|
|
|
2016-04-05 09:24:28 +03:00
|
|
|
// Lock memory and copy contents from DEVMODE (current printer)
|
|
|
|
// to Global Memory DEVMODE
|
|
|
|
LPDEVMODEW devMode = (DEVMODEW*)::GlobalLock(hDevMode);
|
|
|
|
if (!devMode) {
|
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2016-08-22 08:45:49 +03:00
|
|
|
memcpy(devMode, newDevMode.get(), needed);
|
2016-04-05 09:24:28 +03:00
|
|
|
// Initialize values from the PrintSettings
|
|
|
|
nsCOMPtr<nsIPrintSettingsWin> psWin = do_QueryInterface(aPS);
|
|
|
|
MOZ_ASSERT(psWin);
|
|
|
|
psWin->CopyToNative(devMode);
|
|
|
|
|
|
|
|
// Sets back the changes we made to the DevMode into the Printer Driver
|
2016-08-22 08:45:49 +03:00
|
|
|
ret = ::DocumentPropertiesW(gParentWnd, hPrinter, printName, devMode, devMode,
|
|
|
|
DM_IN_BUFFER | DM_OUT_BUFFER);
|
|
|
|
if (ret != IDOK) {
|
2016-04-05 09:24:28 +03:00
|
|
|
::GlobalUnlock(hDevMode);
|
|
|
|
return nsReturnRef<nsHGLOBAL>();
|
2002-05-02 15:50:36 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 09:24:28 +03:00
|
|
|
::GlobalUnlock(hDevMode);
|
|
|
|
|
|
|
|
return globalDevMode.out();
|
2002-05-02 15:50:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// helper
|
2020-07-05 22:00:43 +03:00
|
|
|
static void GetDefaultPrinterNameFromGlobalPrinters(nsAString& aPrinterName) {
|
2020-07-10 22:00:17 +03:00
|
|
|
aPrinterName.Truncate();
|
2020-07-05 22:00:43 +03:00
|
|
|
nsCOMPtr<nsIPrinterList> printerList =
|
|
|
|
do_GetService("@mozilla.org/gfx/printerlist;1");
|
|
|
|
if (printerList) {
|
2020-07-10 22:00:17 +03:00
|
|
|
printerList->GetSystemDefaultPrinterName(aPrinterName);
|
2002-05-02 15:50:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Displays the native Print Dialog
|
|
|
|
static nsresult ShowNativePrintDialog(HWND aHWnd,
|
|
|
|
nsIPrintSettings* aPrintSettings) {
|
|
|
|
// NS_ENSURE_ARG_POINTER(aHWnd);
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintSettings);
|
|
|
|
|
|
|
|
// Get the Print Name to be used
|
2017-08-08 09:07:55 +03:00
|
|
|
nsString printerName;
|
2017-10-09 02:08:09 +03:00
|
|
|
aPrintSettings->GetPrinterName(printerName);
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
// If there is no name then use the default printer
|
2010-12-03 19:21:38 +03:00
|
|
|
if (printerName.IsEmpty()) {
|
|
|
|
GetDefaultPrinterNameFromGlobalPrinters(printerName);
|
2004-12-06 18:29:25 +03:00
|
|
|
} else {
|
2013-04-03 04:27:12 +04:00
|
|
|
HANDLE hPrinter = nullptr;
|
2016-04-05 09:24:28 +03:00
|
|
|
if (!::OpenPrinterW(const_cast<wchar_t*>(
|
|
|
|
static_cast<const wchar_t*>(printerName.get())),
|
|
|
|
&hPrinter, nullptr)) {
|
2004-12-06 18:29:25 +03:00
|
|
|
// If the last used printer is not found, we should use default printer.
|
2010-12-03 19:21:38 +03:00
|
|
|
GetDefaultPrinterNameFromGlobalPrinters(printerName);
|
2004-12-06 18:29:25 +03:00
|
|
|
} else {
|
|
|
|
::ClosePrinter(hPrinter);
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now create a DEVNAMES struct so the the dialog is initialized correctly.
|
2002-09-26 15:38:03 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t len = printerName.Length();
|
2016-04-05 09:24:28 +03:00
|
|
|
nsHGLOBAL hDevNames =
|
|
|
|
::GlobalAlloc(GHND, sizeof(wchar_t) * (len + 1) + sizeof(DEVNAMES));
|
|
|
|
nsAutoGlobalMem autoDevNames(hDevNames);
|
2016-04-08 18:37:04 +03:00
|
|
|
if (!hDevNames) {
|
2010-12-03 19:21:38 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2016-04-08 18:37:04 +03:00
|
|
|
DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames);
|
2010-12-03 19:21:38 +03:00
|
|
|
if (!pDevNames) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-04-03 15:35:27 +04:00
|
|
|
pDevNames->wDriverOffset = sizeof(DEVNAMES) / sizeof(wchar_t);
|
|
|
|
pDevNames->wDeviceOffset = sizeof(DEVNAMES) / sizeof(wchar_t);
|
|
|
|
pDevNames->wOutputOffset = sizeof(DEVNAMES) / sizeof(wchar_t) + len;
|
2002-05-02 15:50:36 +04:00
|
|
|
pDevNames->wDefault = 0;
|
2002-09-26 15:38:03 +04:00
|
|
|
|
2017-08-08 09:07:55 +03:00
|
|
|
memcpy(pDevNames + 1, printerName.get(), (len + 1) * sizeof(wchar_t));
|
2016-04-08 18:37:04 +03:00
|
|
|
::GlobalUnlock(hDevNames);
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
// Create a Moveable Memory Object that holds a new DevMode
|
|
|
|
// from the Printer Name
|
|
|
|
// The PRINTDLG.hDevMode requires that it be a moveable memory object
|
2016-04-05 09:24:28 +03:00
|
|
|
// NOTE: autoDevMode is automatically freed when any error occurred
|
|
|
|
nsAutoGlobalMem autoDevMode(
|
|
|
|
CreateGlobalDevModeAndInit(printerName, aPrintSettings));
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
// Prepare to Display the Print Dialog
|
2008-10-24 09:21:15 +04:00
|
|
|
PRINTDLGW prntdlg;
|
|
|
|
memset(&prntdlg, 0, sizeof(PRINTDLGW));
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
prntdlg.lStructSize = sizeof(prntdlg);
|
|
|
|
prntdlg.hwndOwner = aHWnd;
|
2016-04-05 09:24:28 +03:00
|
|
|
prntdlg.hDevMode = autoDevMode.get();
|
2016-04-08 18:37:04 +03:00
|
|
|
prntdlg.hDevNames = hDevNames;
|
2013-04-03 04:27:12 +04:00
|
|
|
prntdlg.hDC = nullptr;
|
2011-09-29 17:21:32 +04:00
|
|
|
prntdlg.Flags =
|
|
|
|
PD_ALLPAGES | PD_RETURNIC | PD_USEDEVMODECOPIESANDCOLLATE | PD_COLLATE;
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
// if there is a current selection then enable the "Selection" radio button
|
2020-10-07 03:36:51 +03:00
|
|
|
if (!aPrintSettings->GetIsPrintSelectionRBEnabled()) {
|
2002-05-02 15:50:36 +04:00
|
|
|
prntdlg.Flags |= PD_NOSELECTION;
|
|
|
|
}
|
|
|
|
|
2020-09-15 01:28:55 +03:00
|
|
|
int16_t printRangeType = nsIPrintSettings::kRangeAllPages;
|
|
|
|
aPrintSettings->GetPrintRange(&printRangeType);
|
|
|
|
// if there is a specified page range then enable the "Custom" radio button
|
|
|
|
if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) {
|
|
|
|
prntdlg.Flags |= PD_PAGENUMS;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t pg = 1;
|
2003-07-04 12:31:44 +04:00
|
|
|
aPrintSettings->GetStartPageRange(&pg);
|
|
|
|
prntdlg.nFromPage = pg;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2003-07-04 12:31:44 +04:00
|
|
|
aPrintSettings->GetEndPageRange(&pg);
|
|
|
|
prntdlg.nToPage = pg;
|
|
|
|
|
2002-05-02 15:50:36 +04:00
|
|
|
prntdlg.nMinPage = 1;
|
|
|
|
prntdlg.nMaxPage = 0xFFFF;
|
|
|
|
prntdlg.nCopies = 1;
|
2013-04-03 04:27:12 +04:00
|
|
|
prntdlg.lpfnSetupHook = nullptr;
|
|
|
|
prntdlg.lpSetupTemplateName = nullptr;
|
|
|
|
prntdlg.hPrintTemplate = nullptr;
|
|
|
|
prntdlg.hSetupTemplate = nullptr;
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2013-04-03 04:27:12 +04:00
|
|
|
prntdlg.hInstance = nullptr;
|
|
|
|
prntdlg.lpPrintTemplateName = nullptr;
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2019-05-15 12:36:08 +03:00
|
|
|
prntdlg.lCustData = 0;
|
|
|
|
prntdlg.lpfnPrintHook = nullptr;
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2016-07-02 01:58:31 +03:00
|
|
|
BOOL result;
|
|
|
|
{
|
|
|
|
mozilla::widget::WinUtils::AutoSystemDpiAware dpiAwareness;
|
2018-12-13 16:17:14 +03:00
|
|
|
mozilla::BackgroundHangMonitor().NotifyWait();
|
2016-07-02 01:58:31 +03:00
|
|
|
result = ::PrintDlgW(&prntdlg);
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
if (TRUE == result) {
|
2013-04-03 04:27:12 +04:00
|
|
|
// check to make sure we don't have any nullptr pointers
|
2002-10-30 16:31:58 +03:00
|
|
|
NS_ENSURE_TRUE(aPrintSettings && prntdlg.hDevMode, NS_ERROR_FAILURE);
|
|
|
|
|
2013-04-03 04:27:12 +04:00
|
|
|
if (prntdlg.hDevNames == nullptr) {
|
2002-10-30 16:31:58 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2002-05-02 15:50:36 +04:00
|
|
|
}
|
2013-04-03 04:27:12 +04:00
|
|
|
// Lock the deviceNames and check for nullptr
|
2002-05-02 15:50:36 +04:00
|
|
|
DEVNAMES* devnames = (DEVNAMES*)::GlobalLock(prntdlg.hDevNames);
|
2013-04-03 04:27:12 +04:00
|
|
|
if (devnames == nullptr) {
|
2002-10-30 16:31:58 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2013-12-03 19:09:50 +04:00
|
|
|
char16_t* device = &(((char16_t*)devnames)[devnames->wDeviceOffset]);
|
|
|
|
char16_t* driver = &(((char16_t*)devnames)[devnames->wDriverOffset]);
|
2002-09-25 18:12:14 +04:00
|
|
|
|
2002-10-30 16:31:58 +03:00
|
|
|
// Check to see if the "Print To File" control is checked
|
|
|
|
// then take the name from devNames and set it in the PrintSettings
|
|
|
|
//
|
|
|
|
// NOTE:
|
|
|
|
// As per Microsoft SDK documentation the returned value offset from
|
2013-04-03 04:27:12 +04:00
|
|
|
// devnames->wOutputOffset is either "FILE:" or nullptr
|
2002-10-30 16:31:58 +03:00
|
|
|
// if the "Print To File" checkbox is checked it MUST be "FILE:"
|
|
|
|
// We assert as an extra safety check.
|
|
|
|
if (prntdlg.Flags & PD_PRINTTOFILE) {
|
2013-12-03 19:09:50 +04:00
|
|
|
char16ptr_t fileName = &(((wchar_t*)devnames)[devnames->wOutputOffset]);
|
2008-10-24 09:21:15 +04:00
|
|
|
NS_ASSERTION(wcscmp(fileName, L"FILE:") == 0, "FileName must be `FILE:`");
|
2017-10-09 02:08:09 +03:00
|
|
|
aPrintSettings->SetToFileName(nsDependentString(fileName));
|
2011-10-17 18:59:28 +04:00
|
|
|
aPrintSettings->SetPrintToFile(true);
|
2002-10-30 16:31:58 +03:00
|
|
|
} else {
|
|
|
|
// clear "print to file" info
|
2011-10-17 18:59:28 +04:00
|
|
|
aPrintSettings->SetPrintToFile(false);
|
2020-09-23 18:17:15 +03:00
|
|
|
aPrintSettings->SetToFileName(u""_ns);
|
2002-10-30 16:31:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrintSettingsWin> psWin(do_QueryInterface(aPrintSettings));
|
|
|
|
if (!psWin) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup local Data members
|
2017-10-09 02:08:09 +03:00
|
|
|
psWin->SetDeviceName(nsDependentString(device));
|
|
|
|
psWin->SetDriverName(nsDependentString(driver));
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2002-10-30 16:31:58 +03:00
|
|
|
// fill the print options with the info from the dialog
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2017-10-09 02:08:09 +03:00
|
|
|
aPrintSettings->SetPrinterName(nsDependentString(device));
|
2020-10-02 16:59:48 +03:00
|
|
|
aPrintSettings->SetPrintSelectionOnly(prntdlg.Flags & PD_SELECTION);
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2020-10-02 16:59:48 +03:00
|
|
|
if (prntdlg.Flags & PD_PAGENUMS) {
|
2002-10-30 16:31:58 +03:00
|
|
|
aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange);
|
|
|
|
aPrintSettings->SetStartPageRange(prntdlg.nFromPage);
|
|
|
|
aPrintSettings->SetEndPageRange(prntdlg.nToPage);
|
|
|
|
} else { // (prntdlg.Flags & PD_ALLPAGES)
|
|
|
|
aPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages);
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
|
2002-10-30 16:31:58 +03:00
|
|
|
// Unlock DeviceNames
|
|
|
|
::GlobalUnlock(prntdlg.hDevNames);
|
|
|
|
|
|
|
|
// Transfer the settings from the native data to the PrintSettings
|
2008-10-22 04:54:26 +04:00
|
|
|
LPDEVMODEW devMode = (LPDEVMODEW)::GlobalLock(prntdlg.hDevMode);
|
2016-01-22 19:05:19 +03:00
|
|
|
if (!devMode || !prntdlg.hDC) {
|
2002-10-30 16:31:58 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
psWin->SetDevMode(devMode); // copies DevMode
|
2016-01-12 20:40:07 +03:00
|
|
|
psWin->CopyFromNative(prntdlg.hDC, devMode);
|
2002-10-30 16:31:58 +03:00
|
|
|
::GlobalUnlock(prntdlg.hDevMode);
|
2016-01-22 19:05:19 +03:00
|
|
|
::DeleteDC(prntdlg.hDC);
|
2002-05-02 15:50:36 +04:00
|
|
|
} else {
|
2011-02-07 17:47:10 +03:00
|
|
|
::SetFocus(aHWnd);
|
2011-10-17 18:59:28 +04:00
|
|
|
aPrintSettings->SetIsCancelled(true);
|
2002-05-02 15:50:36 +04:00
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
//-- Show Print Dialog
|
|
|
|
//----------------------------------------------------------------------------------
|
2019-12-09 12:04:29 +03:00
|
|
|
nsresult NativeShowPrintDialog(HWND aHWnd, nsIPrintSettings* aPrintSettings) {
|
2011-12-16 13:13:29 +04:00
|
|
|
nsresult rv = ShowNativePrintDialog(aHWnd, aPrintSettings);
|
2010-09-06 18:09:19 +04:00
|
|
|
if (aHWnd) {
|
|
|
|
::DestroyWindow(aHWnd);
|
|
|
|
}
|
2002-05-02 15:50:36 +04:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|