I want to create a index page with some text left aligned and page number right aligned with dots in the middle.
I do it now with a right aligned tab with a dot in Leader property.
The problem is how can I calculate the tab position if page margins change, or if paper orientation changes.
I have the page with in printer units, margins in milimetres and the tab position must be set in screen pixels. It's crazy!
Thanks.
Right align
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
How to convert printer sizes to inches or mm:
As for the screen pixels.
By default, RichView uses the screen resolution, i.e. Screen.PixelsPerInch.
This value depends on the current computer settings. If you want to make it independent, assign positive value (for example, 96) to RichViewPixelsPerInch (global variable from RVFuns).
After that,
SizeInMM = SizeInScreenPixels*127/(5*RichViewPixelsPerInch)
Code: Select all
DC := RV_GetPrinterDC; // from PtblRV unit
// size of printable area in printer pixels
Width := GetDeviceCaps(DC, HORZRES);
Height := GetDeviceCaps(DC, VERTRES);
// "physical" offsets (from paper borders to printable area)
phoX := GetDeviceCaps(DC, PHYSICALOFFSETX);
phoY := GetDeviceCaps(DC, PHYSICALOFFSETY);
// "physical" sizes (size of page, including nonprintable areas)
phW := GetDeviceCaps(DC, PHYSICALWIDTH);
phH := GetDeviceCaps(DC, PHYSICALHEIGHT);
// distances from the page border to the printable area
// (i.e. size of "margins" where the printer cannot print)
{
From left side: phoX
From top side: phoY
From right side: phW-(phoX+Width)
From bottom side: phH-(phoY+Height)
}
// all these values are in pixels (printer pixels)
// in order to convert them to mm:
lpy := GetDeviceCaps(DC, LOGPIXELSY);
lpx := GetDeviceCaps(DC, LOGPIXELSX);
// converting val (in pixels) to mm:
// val*127/(5*lpx) -- for horizontal sizes
// val*127/(5*lpy) -- for vertical sizes
// converting val (in pixels) to inches
// val/lpx -- for horizontal sizes
// val/lpy -- for vertical sizes
// Do not forget to delete DC
DeleteDC(DC);
By default, RichView uses the screen resolution, i.e. Screen.PixelsPerInch.
This value depends on the current computer settings. If you want to make it independent, assign positive value (for example, 96) to RichViewPixelsPerInch (global variable from RVFuns).
After that,
SizeInMM = SizeInScreenPixels*127/(5*RichViewPixelsPerInch)