Here's the complete code update. Again, it starts at line 273:
If m_PositionAtCursor Then
' Position Window at Cursor Location when
' Calendar was created.
'
' Also add an option to position cursor itself in middle of calendar
window
' May 05 - update m_cursorXinitpos and m_cursorYinitpos to reflect
current cursor location when this calendar is opened
' This is done in the modCalendar module when the parent window for the
Calendar is created.
'June 7, 2003 fixing position at cursor logic
' PositionAtCursor = True
' First check to ensure entire calendar window will fit.
' If not MAKE IT!
' COMING IN NEXT RELEASE!
lngRet = GetWindowRect(Application.hWndAccessApp, rc2)
'If the calendar will open off the bottom and RHS of the screen
If ((m_cursorY + (rc3.Bottom - rc3.Top)) > rc2.Bottom) And _
((m_cursorX + (rc3.Right - rc3.Left)) > rc2.Right) Then
With udtRECT
Call apiSetWindowPos(m_Hwnd, 0&, m_cursorX - (rc3.Right - rc3.Left), _
m_cursorY - (rc3.Bottom - rc3.Top), rc3.Right - rc3.Left, rc3.Bottom
- rc3.Top, 0&)
End With
'If the calendar will open off the bottom of the screen
ElseIf (m_cursorY + (rc3.Bottom - rc3.Top)) > rc2.Bottom Then
With udtRECT
Call apiSetWindowPos(m_Hwnd, 0&, m_cursorX, _
m_cursorY - (rc3.Bottom - rc3.Top), rc3.Right - rc3.Left, rc3.Bottom
- rc3.Top, 0&)
End With
'If the calendar will open off the right hand side of the screen
ElseIf (m_cursorX + (rc3.Right - rc3.Left)) > rc2.Right Then
With udtRECT
Call apiSetWindowPos(m_Hwnd, 0&, m_cursorX - (rc3.Right - rc3.Left), _
m_cursorY, rc3.Right - rc3.Left, rc3.Bottom - rc3.Top, 0&)
End With
'The Calendar will fit
Else
With udtRECT
Call apiSetWindowPos(m_Hwnd, 0&, m_cursorX, m_cursorY, rc3.Right -
rc3.Left, _
rc3.Bottom - rc3.Top, 0&)
End With
End If
There's probably a more efficient way of doing it (rather than ElseIf), but
this way worked for me. I have tested it for calendars opening in the top
left, to the right, and to the bottom of the screen only, I'm not sure what
happens if the cursor is at the bottom left, but the logic should make it
open above and to the right of the cursor position.
Dave