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 5 1544
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
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
Now if I could only figure out how to intercept/override the method which
populates window lists, I'll be sitting pretty.
;)
"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
Well, never bloody mind then ;)
It would seem that destroying the handles the way i did ALSO solved my
problem of hooking into the MDI list method. Yay :D
"Rob Mayo" <NO****@NOSPAM.com> wrote in message
news:eP**************@tk2msftngp13.phx.gbl... Now if I could only figure out how to intercept/override the method which populates window lists, I'll be sitting pretty. ;)
"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
Actually, I opened my big mouth too soon. It seems that if my MDI children
don't have menus of their own, Destroying the handles works lovely. But when
they do, the merged menus aren't owner drawn and neither is the window list.
D'oh!
Back to the drawing board.
"Rob Mayo" <NO****@NOSPAM.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl... Well, never bloody mind then ;)
It would seem that destroying the handles the way i did ALSO solved my problem of hooking into the MDI list method. Yay :D
"Rob Mayo" <NO****@NOSPAM.com> wrote in message news:eP**************@tk2msftngp13.phx.gbl... Now if I could only figure out how to intercept/override the method
which populates window lists, I'll be sitting pretty. ;)
"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 > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: news.west.cox.net |
last post by:
I have been writing a practice sliding div navigation script. I am finding
myself in the position where I need to force a div into showing the hover
behavior defined in css.
So my question is...
|
by: Rob Mayo |
last post by:
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...
|
by: anand |
last post by:
Hi All,
Are ownerdraw buttons supported in C# ?
I have an active X control which I would like to use in CSharp.
Buttons have a style BS_OWNERDRAW, and to do custom drawing you have
to...
|
by: Apollo440 |
last post by:
If MenuItem.OwnerDraw Property is true,.NET framework does not recognize
the overlapped accelerator keys.
Is there a workaround?
eg)
+------+
|&Test | <-
|&Tea | <- MenuItems has...
|
by: jm |
last post by:
There are properties for OwnerDraw on ContextMenu items. I know it
can be done with regular menus. I cannot find anyone doing it with
the systray icon contextmenu (notifyicon.) Is it possible to...
|
by: MrNobody |
last post by:
Hey I think I have a problem with the MeasureItem event on a MenuItem.
I am dynamically changing the text in the MenuItem, and if this text becomes
longer than any text in the original menu, it...
|
by: Fabrizio |
last post by:
I've implemented an ownerdraw menu but when I change the Text property of the item MeasureItem is not fired so I can't change the Width of the Item.
So I create a new property Text but I can't...
|
by: Michel |
last post by:
I use the ownerdraw methode to customize my menu.
So, inside the sub OnDrawItem I need to know the size of my form
Do you have any idea to do that.
I dont want to use the reference to the...
|
by: genojoe |
last post by:
This code is derived from:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2005JUL.1033/cpref/html/frlrfSystemWindowsFormsMenuItemClassOwnerDrawTopic.htm
The sample works as presented but does not contain a...
|
by: tmda |
last post by:
I'm using OwnerDraw for some customization in my ListView - adding
color to item backgrounds. I'm using the ListView specifically for
it's OwnerDraw capability. I originally was using the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |