That did it. Thanks Mick
That seems to work very well as a rule when using OwnerDraw menus in
applications. If you're going to change the text of an owner drawn menu
item, remove it, change the text, then re-add it.
Just FYI, since my Component is where all the code lies, and is dependent on
menu events firing, it wasn't really feasible to add code like this here,
but I have a nice little workaraound.
From you telling me to remove the menu and add it again, I looked under the
hood (Using Lutz Roeder's Reflector) at what's going on in the Add method of
the MenuItemCollection class. There I found a method called ItemsChanged().
I examined that method and found another called DestroyMenuItems(). From
that I figured how the menus are getting refreshed.
In my Component, I hook into the Popup event (which fires before the actual
menu pops up), then use reflection to call that method to destroy the
handles on the sub items of the menu.
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Remove the menuitem, modify it's text then reinsert the menuitem.
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Rob Mayo" <NO****@NOSPAM.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... How can I force a MeasureItem message for an owner-dramn menu item?
Here is the dilemma. I wrote a lovely little Component for owner-drawing
all
the menus on a form and making them look like Office XP-style menus
(mostly
an academic exercise). I came across a problem with another app I wrote,
which is using this Component. The app changes the text in the menu
items depending on what is selected in the app. The fisrt time the menu may be
show (when it calls MeasureItem), the menu is appropriately owner-sized
to the text. The next time the menu is shown, the text will be different
(in this case longer). Since MeasureItem is never called again, the menu
cannot
be appropriately sized to the text. In this instance, it cuts off the
text of the longer menu text.
Is there any way I can force Windows to send this message again?
Any help is appreciated.
Thanks in advance
WALDO
MCP, MCAD, MCSD