// Pobierz parametry strony
void TForm1::PobierzParametryStrony(int &PaperSize, int &Orientation)
{
WCHAR cDevice[1024], cDriver[1024], cPort[1024];
THandle hDeviceMode;
PDeviceMode DevMode;
Printer()->GetPrinter(cDevice, cDriver, cPort, hDeviceMode);
DevMode =(_devicemodeW*) GlobalLock((void*)hDeviceMode);
PaperSize = DevMode->dmPaperSize; // DMPAPER_A3, DMPAPER_A4, DMPAPER_A5, ...
Orientation = DevMode->dmOrientation; // DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE
GlobalUnlock((void*)hDeviceMode);
}
//---------------------------------------------------------------------------
// Ustaw parametry strony
void TForm1::UstawParametryStrony(int PaperSize, int Orientation)
{
WCHAR cDevice[1024], cDriver[1024], cPort[1024];
THandle hDeviceMode;
PDeviceMode DevMode;
Printer()->GetPrinter(cDevice, cDriver, cPort, hDeviceMode);
DevMode =(_devicemodeW*) GlobalLock((void*)hDeviceMode);
DevMode->dmFields = DevMode->dmFields | DM_PAPERSIZE;
DevMode->dmFields = DevMode->dmFields | DM_ORIENTATION;
DevMode->dmPaperSize = PaperSize; // DMPAPER_A3, DMPAPER_A4, DMPAPER_A5, ...
DevMode->dmOrientation = Orientation; // DMORIENT_PORTRAIT, DMORIENT_LANDSCAPE
Printer()->SetPrinter(cDevice, cDriver, cPort, hDeviceMode);
GlobalUnlock((void*)hDeviceMode);
}
//---------------------------------------------------------------------------