Problem with OwnerDrawn menu

A

André Nogueira

Hi there!
I have successfully create my own ownerdrawn menus.
However, I decided to add some code for the menus to detect if their parent
is a MainMenu object and, if it is, as it is the menuitem beeing displayed
in the form's menu bar, it draws it differently.
So far so good.
But there are two thing I can't get around.

1 - How can I draw a custom menu when the mouse is over the menu item but
the user hasn't clicked it, just like in Visual Studio or Office 2003?

2 - When the user clicks the menu item, its design changes. However, when
the user moves to another menu (from file to edit, for instance) or when it
closes the menu, it will not redraw. The menu bar will be as if all the menu
items are beeing clicked at the same time.

Any help would be appreciated.
Thank you in advance.

André Nogueira
 
M

Mick Doherty

You need to draw different States and erase the previous state.

Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
MyBase.OnPaint(e)

'Erase Previous State
e.Graphics.FillRectangle(BackcolorBrush, e.Bounds)

If CBool(e.State And DrawItemState.Selected) Or _
CBool(e.State And DrawItemState.HotLight) Then
'Hilighted Item Painting Here
Else
'Normal Item Painting here
End If

End Sub

http://dotnetrix.co.uk/menus.html --> Office style Menu
 
A

André Nogueira

The Office 2003 style is what I am doing ;)
It's nearly done!
Thank you for your help

André Nogueira

"Mick Doherty"
 

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