 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
murn Guest
|
Posted: Wed Nov 26, 2003 2:21 pm Post subject: Convert PageSize to Client pixel? |
|
|
Hi,
I would like to set borders of a TScrollbox based on selected Printer
Paper(A4,A3,...).
I'am trying to set horizontal and vertical scrollbar range property of
TScrollBox component with pagewidth and pageheight provided by
getdevicecaps:
pagewidth:=getdevicecaps(printer.handle,PHYSICALWIDTH);
pageheight:=getdevicecaps(printer.handle,PHYSICALHEIGHT);
I've drawn a scale in cm on top and left of the TScrollbox.
So i would like to convert pagewidth to TScrollBox range(pixel) in
cm.(pixel -> cm).
HorzScrollBar.Range := round(pagewidth);
VertScrollBar.Range := round(pageheight);
Regards,
Milos
|
|
| Back to top |
|
 |
murn Guest
|
Posted: Wed Nov 26, 2003 2:26 pm Post subject: Re: Convert PageSize to Client pixel? |
|
|
Question :
How to convert pagewidth and pageheight provided by API, to client pixel (in
cm)?
Thanx!
|
|
| Back to top |
|
 |
mhb Guest
|
Posted: Wed Nov 26, 2003 4:05 pm Post subject: Re: Convert PageSize to Client pixel? |
|
|
Hi,
The GetDeviceCaps reads the PHYSICALWIDTH and PHYSICALHEIGHT in inches, so
you have to divide it by the printer PixelsPerUnit.
PageWidth := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH) /
GetDeviceCaps(Printer.Handle, LOGPIXELSX);
PageHeight := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT) /
GetDeviceCaps(Printer.Handle, LOGPIXELSY);
For A4 size, the PageWidth will be 8.27 inch and the PageHeight will be
11.69 inch.
To set the scrollbar range you have to calculated the size in
Screen.PixelsPerInch
The size in Pixels:
HorzRange := PageWidth * Screen.PixelsPerInch;
VertRange := PageHeight * Screen.PixelsPerInch;
The size in MM
HorzRange := PageWidth * 25.43; // inch to mm
VertRange := PageHeight * 25.43;
Regards
"murn" <miloo (AT) email (DOT) si> wrote
| Quote: | Question :
How to convert pagewidth and pageheight provided by API, to client pixel
(in
cm)?
Thanx!
|
|
|
| Back to top |
|
 |
murn Guest
|
Posted: Fri Nov 28, 2003 8:23 am Post subject: Re: Convert PageSize to Client pixel? |
|
|
Thanx for the tip it works fine
Regards Milos
"mhb" <mhb_shrf (AT) hotmail (DOT) com> wrote
| Quote: | Hi,
The GetDeviceCaps reads the PHYSICALWIDTH and PHYSICALHEIGHT in inches, so
you have to divide it by the printer PixelsPerUnit.
PageWidth := GetDeviceCaps(Printer.Handle, PHYSICALWIDTH) /
GetDeviceCaps(Printer.Handle, LOGPIXELSX);
PageHeight := GetDeviceCaps(Printer.Handle, PHYSICALHEIGHT) /
GetDeviceCaps(Printer.Handle, LOGPIXELSY);
For A4 size, the PageWidth will be 8.27 inch and the PageHeight will be
11.69 inch.
To set the scrollbar range you have to calculated the size in
Screen.PixelsPerInch
The size in Pixels:
HorzRange := PageWidth * Screen.PixelsPerInch;
VertRange := PageHeight * Screen.PixelsPerInch;
The size in MM
HorzRange := PageWidth * 25.43; // inch to mm
VertRange := PageHeight * 25.43;
Regards
"murn" <miloo (AT) email (DOT) si> wrote in message
news:3fc4b7d2 (AT) newsgroups (DOT) borland.com...
Question :
How to convert pagewidth and pageheight provided by API, to client pixel
(in
cm)?
Thanx!
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|