Board index » delphi » Right-align text on canvas, and scaling???

Right-align text on canvas, and scaling???

How do I right align a text string to the canvas (using the
textout or textrect methods)?

Do I use the textwidth method to find the width for
calculating the starting position, or is there a more direct
way to specify the right coordinate rather than the left
coordinate for the text? (textwidth will of course work!)

While I am at it, I was also searching in vain for the
pixels/Inch property of the canvas associated with my
printer. I need to either be able to force this printer
property to 300ppi (from my program) or to read the
property so that I can build my canvas with the correct
scaling.

Suggestions anyone?

regards Sven

 

Re:Right-align text on canvas, and scaling???


Quote
"Sven Pran" <Sven.P...@alcatel.no> wrote in message

news:8kt2q6$g6n$1@netox20.alcatel.no...

Quote
> How do I right align a text string to the canvas (using the
> textout or textrect methods)?

> Do I use the textwidth method to find the width for
> calculating the starting position, or is there a more direct
> way to specify the right coordinate rather than the left
> coordinate for the text? (textwidth will of course work!)

> While I am at it, I was also searching in vain for the
> pixels/Inch property of the canvas associated with my
> printer. I need to either be able to force this printer
> property to 300ppi (from my program) or to read the
> property so that I can build my canvas with the correct
> scaling.

> Suggestions anyone?

Use the Windows API for all of this.

1. To justify text use the DrawText call, e.g.
            DrawText (aCanvas.Handle, pChar (aString), -1, aRect,
DT_SingleLine or DT_Right)
    DrawText is very versatile and quite easy to use. The aRect parameter
defines the dimensions of the rectangle in which the text is to be printed.
2. Use GetDeviceCaps to get the horizontal and vertical pixels per inch of
the printer:
        horizontalPPI := GetDeviceCaps (Printer.Handle, LogPixelSX);
        verticalPPI := GetDeviceCaps (Printer.Handle, LogPixelSY);
    You can get similar and more detailed information using
DeviceCapabilities.

Re:Right-align text on canvas, and scaling???


Thanks!
I will try all this
regards Sven
Quote
Bruce Roberts <no.junk.please....@attcanada.net> wrote in message

news:ckwc5.29778$qS3.64182@tor-nn1.netcom.ca...
Quote

> "Sven Pran" <Sven.P...@alcatel.no> wrote in message
> news:8kt2q6$g6n$1@netox20.alcatel.no...
> > How do I right align a text string to the canvas (using the
> > textout or textrect methods)?

> > Do I use the textwidth method to find the width for
> > calculating the starting position, or is there a more direct
> > way to specify the right coordinate rather than the left
> > coordinate for the text? (textwidth will of course work!)

> > While I am at it, I was also searching in vain for the
> > pixels/Inch property of the canvas associated with my
> > printer. I need to either be able to force this printer
> > property to 300ppi (from my program) or to read the
> > property so that I can build my canvas with the correct
> > scaling.

> > Suggestions anyone?

> Use the Windows API for all of this.

> 1. To justify text use the DrawText call, e.g.
>             DrawText (aCanvas.Handle, pChar (aString), -1, aRect,
> DT_SingleLine or DT_Right)
>     DrawText is very versatile and quite easy to use. The aRect parameter
> defines the dimensions of the rectangle in which the text is to be
printed.
> 2. Use GetDeviceCaps to get the horizontal and vertical pixels per inch of
> the printer:
>         horizontalPPI := GetDeviceCaps (Printer.Handle, LogPixelSX);
>         verticalPPI := GetDeviceCaps (Printer.Handle, LogPixelSY);
>     You can get similar and more detailed information using
> DeviceCapabilities.

Re:Right-align text on canvas, and scaling???


Thanks!
I will try all this
regards Sven

Quote
Bruce Roberts <no.junk.please....@attcanada.net> wrote in message

news:ckwc5.29778$qS3.64182@tor-nn1.netcom.ca...
Quote

> "Sven Pran" <Sven.P...@alcatel.no> wrote in message
> news:8kt2q6$g6n$1@netox20.alcatel.no...
> > How do I right align a text string to the canvas (using the
> > textout or textrect methods)?

> > Do I use the textwidth method to find the width for
> > calculating the starting position, or is there a more direct
> > way to specify the right coordinate rather than the left
> > coordinate for the text? (textwidth will of course work!)

> > While I am at it, I was also searching in vain for the
> > pixels/Inch property of the canvas associated with my
> > printer. I need to either be able to force this printer
> > property to 300ppi (from my program) or to read the
> > property so that I can build my canvas with the correct
> > scaling.

> > Suggestions anyone?

> Use the Windows API for all of this.

> 1. To justify text use the DrawText call, e.g.
>             DrawText (aCanvas.Handle, pChar (aString), -1, aRect,
> DT_SingleLine or DT_Right)
>     DrawText is very versatile and quite easy to use. The aRect parameter
> defines the dimensions of the rectangle in which the text is to be
printed.
> 2. Use GetDeviceCaps to get the horizontal and vertical pixels per inch of
> the printer:
>         horizontalPPI := GetDeviceCaps (Printer.Handle, LogPixelSX);
>         verticalPPI := GetDeviceCaps (Printer.Handle, LogPixelSY);
>     You can get similar and more detailed information using
> DeviceCapabilities.

Other Threads