R
Randy
I'm struggling with identifying whether a user has clicked on the left
or right arrows within the MonthCalendar controls. I had a good
suggestion to trap the mouse coordinates that the user clicks to
determine if they have clicked within the region where the arrow
exists. My problem is that my form is not maximized and therefore the
control can exist almost anywhere on the user's screen. I thought
about forcing the form to a fixed position, but I'd rather not do this
unless I have to.
What I thought might work would be to calculate the coordinate that
the user clicked relative to the position of the form since the
control is always in the same place relative to the form itself. Here
is the code that I am working on (excerpted):
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e
As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Dim x As Integer = Val(System.Windows.Forms.Cursor.Position.X) -
Val(Me.MonthCalendar1.Location.X)
Dim y As Integer = Val(System.Windows.Forms.Cursor.Position.Y) -
Val(Me.MonthCalendar1.Location.Y)
Dim d As Date = e.Start
If x < ????? Then
If y < ????? Then
Me.Text = x & ", " & y & " Left arrow clicked"
End If
End If
End Sub
I thought that this would work, but I'm not getting predictable values
of x and y. Can anybody help me figure out how to do this?
Thanks,
Randy
or right arrows within the MonthCalendar controls. I had a good
suggestion to trap the mouse coordinates that the user clicks to
determine if they have clicked within the region where the arrow
exists. My problem is that my form is not maximized and therefore the
control can exist almost anywhere on the user's screen. I thought
about forcing the form to a fixed position, but I'd rather not do this
unless I have to.
What I thought might work would be to calculate the coordinate that
the user clicked relative to the position of the form since the
control is always in the same place relative to the form itself. Here
is the code that I am working on (excerpted):
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e
As System.Windows.Forms.DateRangeEventArgs) Handles
MonthCalendar1.DateChanged
Dim x As Integer = Val(System.Windows.Forms.Cursor.Position.X) -
Val(Me.MonthCalendar1.Location.X)
Dim y As Integer = Val(System.Windows.Forms.Cursor.Position.Y) -
Val(Me.MonthCalendar1.Location.Y)
Dim d As Date = e.Start
If x < ????? Then
If y < ????? Then
Me.Text = x & ", " & y & " Left arrow clicked"
End If
End If
End Sub
I thought that this would work, but I'm not getting predictable values
of x and y. Can anybody help me figure out how to do this?
Thanks,
Randy