Levente
asked on
Query page size BEFORE printing
I need to know the width and height (in pixels) of the page which in my printer. Delphi provides a way to query it:
Printer.PageWidth and Printer.PageHeight contains the above values of the page which is BEING printed.
How can I query the size in pixels of the selected page in the selected printer BEFORE Printer.StartDoc?
Thank you,
Levente
Printer.PageWidth and Printer.PageHeight contains the above values of the page which is BEING printed.
How can I query the size in pixels of the selected page in the selected printer BEFORE Printer.StartDoc?
Thank you,
Levente
Listening
ASKER
Mike,
I'm affraid, I must reject your answer. This call queries the PHYSICAL size of the page in tenths of milimetes. I need the logical one in pixels.
Br,
Levente
I'm affraid, I must reject your answer. This call queries the PHYSICAL size of the page in tenths of milimetes. I need the logical one in pixels.
Br,
Levente
Hi Levente,
You can use the DevMode.dmPelsWidth and DevMode.dmPelsHeight fields to find this out.
Cheers,
Raymond.
You can use the DevMode.dmPelsWidth and DevMode.dmPelsHeight fields to find this out.
Cheers,
Raymond.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Mike: What about the DevMode.dmPelsWidth and DevMode.dmPelsHeight fields?
Cheers,
Raymond.
Cheers,
Raymond.
They do not contain useful values (equal to 0)...
ASKER
Thank you for your code. It finally works.
Glad to help.
Ciao, Mike
Ciao, Mike
try out this code:
procedure TMainForm.Button7Click(Sen
var
Buffer: array[0..255] of Char;
DeviceMode: THandle;
DevMode: PDevMode;
begin
Printer.GetPrinter(Buffer,
DevMode := GlobalLock(DeviceMode);
ShowMessage(IntToStr(DevMo
GlobalUnlock(DeviceMode);
end;
Ciao, Mike