By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,061 Members | 1,539 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,061 IT Pros & Developers. It's quick & easy.

Problem with OwnerDrawn menu

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"André Nogueira" <an**@netcabo.pt.NOSPAM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
Nov 20 '05 #2

P: n/a
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

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"André Nogueira" <an**@netcabo.pt.NOSPAM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004
Nov 20 '05 #3

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

André Nogueira

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:uR**************@TK2MSFTNGP12.phx.gbl...
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

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"André Nogueira" <an**@netcabo.pt.NOSPAM> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.719 / Virus Database: 475 - Release Date: 12/07/2004

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.