Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 22nd, 2010, 06:56 PM
Registered User
 
Join Date: Jan 2008
Location: , , .
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
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 06:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.