Program works again after removing this code (after PrinterSetupDialog1 and before PrintImage):
if (PrintCopies > 0)
{
Printers::TPrinterOrientation orient2 = MyPrinter->Orientation;
wchar_t ADevice[MAX_PATH]; // Printer Name ADevice[CCHDEVICENAME]
wchar_t ADriver[MAX_PATH]; // Name of driver ADriver[MAX_PATH]
wchar_t APort[MAX_PATH]; // PortName/File/UNC Path APort[MAX_PATH]
THandle ADeviceMode; // Handle to the memory area containing the DEVMODE structure
PDEVMODE DevMode;
MyPrinter->GetPrinter(ADevice, ADriver, APort, ADeviceMode);
if (ADeviceMode)
{
DevMode = (PDEVMODE)GlobalLock((void*)ADeviceMode);
if (DevMode != NULL)
{
DevMode->dmCopies = PrintCopies;
if (prn_collate == true)
{
DevMode->dmCollate = DMCOLLATE_TRUE;
}
else
{
DevMode->dmCollate = DMCOLLATE_FALSE;
}
if (orient2 == poLandscape) DevMode->dmOrientation = DMORIENT_LANDSCAPE;
if (orient2 == poPortrait) DevMode->dmOrientation = DMORIENT_PORTRAIT;
//DevMode->dmFields = DM_COLLATE | DM_COPIES;
DevMode->dmFields = DM_COLLATE | DM_COPIES | DM_ORIENTATION;
MyPrinter->SetPrinter(ADevice, ADriver, APort, ADeviceMode);
}
GlobalUnlock(DevMode);
}
}
Why? How to fix it?
I need to change
DevMode->dmCopies
DevMode->dmCollate
DevMode->dmOrientation
Is there other way?