BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert PageSize to Client pixel?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
murn
Guest





PostPosted: Wed Nov 26, 2003 2:21 pm    Post subject: Convert PageSize to Client pixel? Reply with quote



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





PostPosted: Wed Nov 26, 2003 2:26 pm    Post subject: Re: Convert PageSize to Client pixel? Reply with quote



Question :
How to convert pagewidth and pageheight provided by API, to client pixel (in
cm)?

Thanx!


Back to top
mhb
Guest





PostPosted: Wed Nov 26, 2003 4:05 pm    Post subject: Re: Convert PageSize to Client pixel? Reply with 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

Quote:
Question :
How to convert pagewidth and pageheight provided by API, to client pixel
(in
cm)?

Thanx!





Back to top
murn
Guest





PostPosted: Fri Nov 28, 2003 8:23 am    Post subject: Re: Convert PageSize to Client pixel? Reply with quote

Thanx for the tip Smile 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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.