Wrox Programmer Forums
|
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 22nd, 2010, 05:56 PM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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





Similar Threads
Thread Thread Starter Forum Replies Last Post
OnMouseHover Issue (Bug?) pagates General .NET 0 February 4th, 2005 09:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.