onmousehover crisis
Hi,
I am looking for a solution to use the onmousehover event on a rectangle shape using shape.isvisible(e.X, e.Y).
I am making a calendar exactly as the MS Outlook Calendar.
I have drawn a rectangle, filled it with a gradient solid color brush, added drawstrings (text) and now want that shape to recognize onmousehover event so I can change the color from blue to yellow (highlighting Day/Week/Month).
Problem is that only mouseeventargs support mousedown with shape.isvisible (e.X, eY) and that system.eventargs (mouseonhowver) doesn't support the shape.isvisible feature.
I have been looking into overriding the handler but it conflicts with my.base event handling, and I can't find a proper example or information about how to with an addhandler event (if at all possible). Also declaring the shape with the withevents argument doesn't solve the problem...
Please some help is appreciated.Below some code
PrivateSub Calendar_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) HandlesMyBase.Paint
'Capture Screen Width and Height to resize the Menubar Drawing.
Me.BackColor = Color.FromArgb(227, 239, 255)
Dim hResize AsInteger = Me.Width
Dim vResize AsInteger = Me.Height
'Set Smooting Option to Anti-Alias.
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
'Create a solid color brush to customize brush colors.
Dim blueBrush AsNew SolidBrush(Color.FromArgb(172, 208, 255))
'Create a solid color Pen to customize pen color.
Dim bluepens AsNew Pen(Color.FromArgb(156, 171, 190))
'Create a path for the rectangle, using scalable width (hResize).
Dim pathRect AsNew Rectangle(0, 0, hResize, 30)
TopMenuBar = New Drawing2D.GraphicsPath()
TopMenuBar.StartFigure()
TopMenuBar.AddRectangle(pathRect)
TopMenuBar.CloseFigure()
'Draw the rectangle via its give path and colors.
e.Graphics.FillPath(blueBrush, TopMenuBar)
e.Graphics.DrawPath(bluepens, TopMenuBar)
'I left out the code for a Day button and Month button since they are coded the same.'Draw the Week button.
'Create a path for the rectangle.
Dim pathMonthButtonRect AsNew Rectangle(140, 0, 70, 30)
Monthbutton = New Drawing2D.GraphicsPath()
Monthbutton.StartFigure()
Monthbutton.AddRectangle(pathMonthButtonRect)
Monthbutton.CloseFigure()
'Draw the rectangle via its give path and colors.
e.Graphics.FillPath(GradientMonthBrush, Monthbutton)
e.Graphics.DrawPath(bluepens, Monthbutton)
'Draw the Text inside the Buttons.
Dim ButtonFont AsNew Font("Tahoma", 8, FontStyle.Regular, GraphicsUnit.Point)
e.Graphics.DrawString("Day", ButtonFont, Brushes.Black, 24, 8)
e.Graphics.DrawString("Week", ButtonFont, Brushes.Black, 90, 8)
e.Graphics.DrawString("Month", ButtonFont, Brushes.Black, 158, 8)
'Here dispose of all used resourses.
'Removed since it adds no value to this question
EndSub
'Doubleclick on shape, will eventually repaint the form into a day-week calendar
PrivateSub CalendarButtons_MouseDown(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) HandlesMyBase.MouseDoubleClick
If Daybutton.IsVisible(e.X, e.Y) Then
MessageBox.Show("Change Calender into Day Calendar")
ElseIf Weekbutton.IsVisible(e.X, e.Y) Then
MessageBox.Show("Change Calender into Week Calendar")
ElseIf Monthbutton.IsVisible(e.X, e.Y) Then
MessageBox.Show("Change Calender into Month Calendar")
EndIf
EndSub
|