Jump to content

Where is the Y position for _WinAPI_TextOut

Recommended Posts

The _WinAPI_TextOut() function requires a x/y point.  In a rectangle enclosing a text character, where is the x/y point, upper left or lower left?  I'm trying to setup a function to print a header, then normal text lines, and I want the header to be at the top of the printable area on a page..  I use _WinAPI_GetDeviceCaps() to get the start of the printable area.  Then at the start of each page, I want to print a header, then text lines.

$iLeftMargin_X = _WinAPI_GetDeviceCaps($hDC, $PHYSICALOFFSETX) ; returns 151
$iTopMargin_Y = _WinAPI_GetDeviceCaps($hDC, $PHYSICALOFFSETY) ; returns 70

; print the header:
$x = $iLeftMargin_X
$y = $iTopMargin_Y
WinAPI_TextOut($hDC, $x , $y, "header text")

; print the first text line
$y += 22
WinAPI_TextOut($hDC, $x , $y, "The first text line")

Will the header text be at the physical top of the printable area or will it be 1 text line lower.  It all depends on whether $iTopMargin_Y refers to the top of the text or the bottom of the text.

Link to comment
Share on other sites

As with all these types of questions the answer is to try it and see where the text is placed.
From MSDN 


For printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the topmost 0.5-inch of paper, has a vertical physical offset of 300 device units.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...