Lebans Calendar Control

G

Guest

I use Leban's excellent calendar control on my forms. However, I have one
small problem. The button I use to open the control is to the far right of
the screen. When I open the calendar, it appears to the bottom right of the
button, making it appear partially off-screen. Is there any way to solve this?

Thanks,

Dave
 
G

Guest

With the calendar open, click properties, then calendar locations. I use
"curser location when calendar is opened" and it is always perfectly in the
correct position, right under the date field. If that does not work, play
with the other options.
 
G

Guest

Sorted it now. The logic to detect if the control will fit on the screen
hasn't been added yet, so I added it. Works a charm.

Thanks,

Dave
 
S

Stephen Lebans

David why don't you post your code here so I can paste it to the
MonthCalendar Web page.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

Guest

My VBA isn't particularly great, but I managed to get it all to work. The
code 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 (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

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


As you can see I haven't commented it. Currently it only calculates if the
control will disappear off the right hand side of the Access Window. I will
look at checking if it will disappear off the bottom of the window today. You
don't need to check any other positions (left hand or top), since it displays
below and to the right of the cursor by default.

Dave
 
G

Guest

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
 
S

Stephen Lebans

Thanks, that's great David. I'll post it to my Web site during the next
update.
:)

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top