Owner Draw Menu Item

  • Thread starter Devron Blatchford
  • Start date
D

Devron Blatchford

Hi there,

I have created an owner draw menu item using DrawItem and MeasureItem in
VB.NET. This seems to work well. I was wondering how I can do mouse over
effects in these menus. Basically the same as the dot net menus where they
get highlighted when the mouse moves over them.

Does anyone have any VB dot net examples or suggestions on how I could do
this?

Thanks
Devron
 
D

Devron Blatchford

How do I handle the mouse_leave event to know when the mouse leaves the
item.?

Thanks
Devron
 
T

Tom Spink

Hi Devron, You don't want to be looking at those events, you need to be
using the Draw Item event.

Inside the draw item even, we have the 'e' class (declared as
DrawItemEventArgs) and it allows you to draw the item depending on the state
of the item:

' /// Inside DrawItem

If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
' The item is currently selected, fill with blue
Else
' The item is not selected, fill with white
End If

'///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
H

Herfried K. Wagner [MVP]

Devron Blatchford said:
I have created an owner draw menu item using DrawItem and MeasureItem in
VB.NET. This seems to work well. I was wondering how I can do mouse over
effects in these menus. Basically the same as the dot net menus where they
get highlighted when the mouse moves over them.

Does anyone have any VB dot net examples or suggestions on how I could do
this?

<http://www.msjogren.net/dotnet/eng/samples/dotnet_iconmenu.asp>
 
M

Mick Doherty

' /// Inside DrawItem
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
' The item is currently selected, fill with blue
Else
' The item is not selected, fill with white
End If

'///

For the TopLevel Menus(File, Edit etc...) you may also want to check for
DrawItemState.Hotlight.

' /// Inside DrawItem

If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
' The item is currently selected, fill with blue
ElseIf (e.State And DrawItemState.HotLight) = DrawItemState.Selected Then
'The Item is currently Hot, fill with yellow
Else
' The item is not selected or hot, fill with systemcolors.menu
End If

'///
 
T

Tom Spink

Hi Mick, slight error in your code:
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
' The item is currently selected, fill with blue

' /// Slight error
ElseIf (e.State And DrawItemState.HotLight) = DrawItemState.Selected Then
' ///
'The Item is currently Hot, fill with yellow
Else
' The item is not selected or hot, fill with systemcolors.menu
End If

It should read

' ///
ElseIf (e.State And DrawItemState.HotLight) = DrawItemState.HotLight Then
' ///

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
M

Mick Doherty

Well spotted. That's what happens when you cut/paste and edit without
checking.
Of course, had I done this in VS.Net I would have instantly noticed it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top