[AccessD] For API experts only

Bruce Bruen bbruen at bigpond.com
Fri Jul 18 07:26:53 CDT 2003


Hey list,

Can anyone tell me what units the following call returns:
	Private Declare Function GetClientRect Lib "user32.dll" (ByVal
hwnd As Long, lpRect As RECT) As Long

Private Type RECT
    wLeft As Long
    wTop As Long
    wRight As Long
    wBottom As Long
End Type

I am trying to set a form detail section height to the maximum available
height in the access client window. To do this I am using
	Private Declare Function GetParent Lib "user32.dll" (ByVal hwnd
As Long) As Long
to get the forms parent window, which appears to have the same hwnd as
the Access app MDI client ( as per the Ashsish/Kreft class info wizard),
and which I thus presume is the window I am looking for.  Then I treat
it thus:

    lRtn = GetClientRect(GetParent(Me.hwnd), wParRECT)
    wincliHeight = wParRect.wBottom * TwipsPerPixelY

Where 

Function TwipsPerPixelY() As Single
'Returns the height of a pixel, in twips.
' This code is from the great but defunct AllAPI team, I think.

    Const HWND_DESKTOP As Long = 0
    Const LOGPIXELSY As Long = 90
  
    Dim lngDC As Long
    
    lngDC = GetDC(HWND_DESKTOP)
    TwipsPerPixelY = 1370& / GetDeviceCaps(lngDC, LOGPIXELSY)
'LOGPIXELSY= Number of pixels per logical inch along the screen height.
    ReleaseDC HWND_DESKTOP, lngDC
End Function

However, this gets me a detail section size that is almost, but not
quite, right.  Its out by about 1cm! 

The screen is running at 1024x768 res.  TwipsPerPixelY returns
14.something.

Any ideas?
Tia
Bruce



More information about the AccessD mailing list