Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

Images for Menu Items?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lynn Morrison - 25 Sep 2004 07:18 GMT
I cannot find this feature at all. There is no bitmap property for menu
items nor is there an imagelist property for the menu itself...

How do I put images to the left of menu items?

Thanks,

Lynn
Libertadrian - 28 Sep 2004 05:13 GMT
Hello Lynn,

You'll have to set the MenuItems OwnerDraw property to true, and then write
some code on the DrawItem and MeasureItem events to draw the menu items by
yourself.

Unfortunately (please take note .NET guys!) there is no "Tag" property on
the MenuItem class as to redirect all menu items events to the same handlers
and use the Tag as an index to an ImageList. So I guess you'll have to:

* Write a specific draw event for each item

-or-

* Somehow use the sender index (if rational) to address the image to draw

-or-

* Create your own class inheriting from MenuItem in a sepparate dll that
Adds ImageList and ImageIndex property and do the drawing.

To draw the item, you'll have to use the passed DrawItemEventArgs in the
DrawItem handler, that has a graphics object to use to draw plus some handy
methods as to fill the background with the proper colors, get the text color,
etc.

As mentioned above, you will also need to write a handler for MeasureItem as
to tell to Windows to add the extra space the bitmaps will take.

Hope it helps.

Libertadrian

"Give me freedom or give me death"

> I cannot find this feature at all. There is no bitmap property for menu
> items nor is there an imagelist property for the menu itself...
[quoted text clipped - 4 lines]
>
> Lynn
Lynn Morrison - 30 Sep 2004 02:30 GMT
> Unfortunately (please take note .NET guys!) there is no "Tag" property on
> the MenuItem class as to redirect all menu items events to the same handlers
[quoted text clipped - 18 lines]
> As mentioned above, you will also need to write a handler for MeasureItem as
> to tell to Windows to add the extra space the bitmaps will take.

   Wow, what a kludge. As images on menus is a common occurence, I find it
hard to believe that the .NET people did not incorporate this functionality
into the menu components when designing it in the first place.

Thanks for the help. I may see if it is difficult to perhaps derive from the
menu to include that feature. I think it would be widely accepted by the
community, if I am not mistaken. My goal is to have an imagelist attached to
the menu and then just set imageindex to the desired image for each of the
menu items...

Thanks again,

Lynn
Libertadrian - 30 Sep 2004 03:59 GMT
There is another method using IExtenderProvider. It's for C#, I didn't try
it, but you should be able to adapt it to C++.

http://www.thecodeproject.com/cs/menu/menuimage.asp

> > Unfortunately (please take note .NET guys!) there is no "Tag" property on
> > the MenuItem class as to redirect all menu items events to the same
[quoted text clipped - 36 lines]
>
> Lynn
Wim Morrison - 30 Sep 2004 07:55 GMT
> There is another method using IExtenderProvider. It's for C#, I didn't try
> it, but you should be able to adapt it to C++.
[quoted text clipped - 41 lines]
> >
> > Lynn

There is an enormous kludge that works easily. Take the image, and
shrink it to 12x12. Then use it as the 'checkmark' image for the menu
item. If you set it to the 'no check' item and do not checkmark the item
then you only need 1 12x12 bitmap.
Signature

Wim Morrison
abuse@html.com.au


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.