473,499 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MouseOver Menu VB.NET

Hi All,

I want to update the statusbar when mouse over on the each menu item. How
to write the code for this. Is there any specific events in menu?

Thanks and Regards
S. Viswanathan
Nov 21 '05 #1
2 2607
Hi,

I dont know of any specific mouse enter and leave events. You can
an owner drawn menu to know when the mouse is over an item and use a timer
to clear the text in the status bar. You need four menu items for this to
work mnufile, mnufileopen, mnufileclose, mnufilequit. All the mnuitems but
mnufile need to be set to ownerdrawn. mnuFile is the top level menuitem.
Hope this helps.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

StatusBar1.Text = ""

End Sub

Private Sub mnuFileClose_MeasureItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.MeasureItemEventArgs) Handles mnuFileClose.MeasureItem,
mnuFileOpen.MeasureItem, mnuFileQuit.MeasureItem

Dim g As Graphics = e.Graphics

Dim mnu As MenuItem = CType(sender, MenuItem)

Dim sz As SizeF = g.MeasureString(mnu.Text.ToString, Me.Font)

e.ItemHeight = CInt(sz.Height) + 5

e.ItemWidth = CInt(sz.Width) + 15

End Sub

Private Sub mnuFileClose_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles mnuFileClose.DrawItem,
mnuFileOpen.DrawItem, mnuFileQuit.DrawItem

Dim br As Brush = SystemBrushes.WindowText

Dim brBack As Brush

Dim rDraw As Rectangle

Dim r As Rectangle = e.Bounds

Dim mnu As MenuItem = CType(sender, MenuItem)

Dim strText As String = mnu.Text.ToString

Dim x As Integer = r.X + 2

Dim y As Integer = r.Y + 2

Dim bEnabled As Boolean = mnu.Enabled

Dim bSelected As Boolean = CBool(e.State And DrawItemState.Selected)

Dim g As Graphics = e.Graphics

rDraw = r

rDraw.Inflate(-1, -1)

g.FillRectangle(New SolidBrush(Color.FromArgb(128, SystemColors.Menu)), r)

If Not bEnabled Then

g.DrawString(strText, Me.Font, Brushes.Gray, 20, r.Y + 3)

Return

End If

If bSelected Then

brBack = Brushes.LightBlue

g.FillRectangle(Brushes.LightBlue, rDraw)

g.DrawRectangle(Pens.Blue, rDraw)

StatusBar1.Text = strText

tmrClearStatusBar.Interval = 3000 ' 3 second

tmrClearStatusBar.Enabled = True

Else

brBack = SystemBrushes.Menu

g.FillRectangle(brBack, r)

End If

g.DrawString(strText, Me.Font, Brushes.Black, 2, r.Y + 3)

br = Nothing

brBack = Nothing

rDraw = Nothing

End Sub

Private Sub tmrClearStatusBar_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmrClearStatusBar.Tick

StatusBar1.Text = ""

tmrClearStatusBar.Enabled = False

End Sub

Ken

-----------------------------------

"S. Viswanathan" <vi**@ewaksoft.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
Hi All,

I want to update the statusbar when mouse over on the each menu item. How
to write the code for this. Is there any specific events in menu?

Thanks and Regards
S. Viswanathan

Nov 21 '05 #2
"S. Viswanathan" <vi**@ewaksoft.com> schrieb:
I want to update the statusbar when mouse over on the each menu item. How
to write the code for this. Is there any specific events in menu?


Add a handler to the menuitem's 'Select' event and update the statusbar
there.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5480
by: OysterCracker | last post by:
Hi - I've previously used js to swap images on mouseover in a menu. I'm stumped on a different situation and would appreciate some advice. I would like to swap imageA to ImageB when I mouseover...
8
78162
by: al | last post by:
Hi, I've been trying to create a image mouseOver effect using CSS - is this possible? Or will I have to use DIV tags or something along those lines? I've tried a number of things - the code...
2
7256
by: Marita | last post by:
I know that you can change the cell background color on mouseover, but is there a way with stylesheets that a background image can be swapped? Thanks in advance for any advice! Marita
1
1837
by: Com Dot | last post by:
In a frameset, the menu frame has six buttons. I would like to use mouseOver on these buttons to make images change in another frame. Does anyone have a script or know of a working site where this...
2
5145
by: Mitch | last post by:
I am hosting a web browser ctl in a container that implements the IDocHostUIHandler interface. I'm using this to control the context menu.This works fine. Then, I added a mouseover event to the...
2
2745
by: Calvin KD | last post by:
Hi everyone, Can someone show me or point me in the right direction as how to create a "dropdown menu" which displays the menu items as a separete layer over the top of the contents of the page...
5
2376
by: JB | last post by:
I am struggling to figure out a way to allow one element to be dragged, but still capture 'mouseover' events on other elements. I've created a simple example to demonstrate what I mean:...
2
3996
by: Amy | last post by:
<style> div.helpBtn{ font:bold 73% verdana; color:#995F8D; text-align:left; width:79px; height:24px; margin:0px; padding: 5px 0px 0px 27px; background:...
11
1735
by: gdp | last post by:
hi - hope someone can suggest a way round this see http://www.tidybit.com/public/ this is a stripped down version of a site i am doing. when you mouseover the artist names on the left - the...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.