Hello,
Thanks for the replies.
My code works in one computer with Win10, access 2016 but I have this problem in another computer.
My code is calculating the co-ordinates of a text box and moves a form there like a DatePicker.
Dim hDC As LongLong, lngRetVal As LongLong
hDC = apiGetDC(hWndAccessApp)
XPIXELSPERINCH = apiGetDeviceCaps(hDC, LOGPIXELSX)
YPIXELSPERINCH = apiGetDeviceCaps(hDC, LOGPIXELSY)
lngRetVal = apiReleaseDC(hWndAccessApp, hDC)
'''''''''''''''''''''''''''''''''''''''''''''''''''
Dim hWndTextBox As LongLong, rectTextBox As RECT_Type
Dim hWndMDIClient As LongLong, rectMDIClient As RECT_Type
Forms(aa).Controls(bb).SetFocus
hWndTextBox = apiGetFocus()
lngRetVal = apiGetWindowRect(hWndTextBox, rectTextBox)
hWndMDIClient = apiFindWindowEx(hWndAccessApp, 0, "MDIClient", vbNullString)
lngRetVal = apiGetWindowRect(hWndMDIClient, rectMDIClient)
' Make metrics relative to the MDIClient window
With rectTextBox
.Bottom = .Bottom - rectMDIClient.Top - apiGetSystemMetrics(SM_CYBORDER)
.Left = .Left - rectMDIClient.Left - apiGetSystemMetrics(SM_CXBORDER)
.Right = .Right - rectMDIClient.Left - apiGetSystemMetrics(SM_CXBORDER)
.Top = .Top - rectMDIClient.Top - apiGetSystemMetrics(SM_CYBORDER)
End With
' Convert the measurements from pixels to twips.
With rectTextBox
.Bottom = .Bottom * (TWIPSPERINCH / XPIXELSPERINCH)
.Left = .Left * (TWIPSPERINCH / XPIXELSPERINCH)
.Right = .Right * (TWIPSPERINCH / XPIXELSPERINCH)
.Top = .Top * (TWIPSPERINCH / XPIXELSPERINCH)
End With
Me.Move Left:=rectTextBox.Left, Top:=rectTextBox.Bottom
hWndAccessApp returns 66578 on the computer which works and returns 328548 on the other.
?????