473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Images for Menu Items?

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
Nov 17 '05 #1
4 1739
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"

"Lynn Morrison" wrote:
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

Nov 17 '05 #2
> 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.


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
Nov 17 '05 #3
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

"Lynn Morrison" wrote:
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.


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

Nov 17 '05 #4
In article <81**********************************@microsoft.co m>,
Li**********@discussions.microsoft.com says...
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

"Lynn Morrison" wrote:
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.


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

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.
--
Wim Morrison
ab***@html.com.au
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lijun Yang | last post by:
Hey, I am able to disable the right mouse button on images for netscape and IE but it won't work for Opera. Here is the code: // start of the code var clickmessage="Sorry, you don't have...
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
3
by: John Ortt | last post by:
Hi everyone, I posted with the title "Javascript Menu Not Loading Images" last week but I only posted the code as the site was on a corporate Intranet. Thanks to advice on the thread I have...
1
by: Will Pittenger | last post by:
I have a program where I used Win32 calls to add items to my form's system menu. Now I am attempting to have those items use the same icon that the corresponding toolbar button uses. I thought...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
3
by: Sumit Gupta | last post by:
How to Add Images to Menu Items in .Net Sumit
2
by: Tull Clancey | last post by:
Hi. I have an application with several menus, see last post, still not resolved. I have another problem.... The menus have been created using the menu editor, I can't find a way to add...
1
by: Carl Gilbert | last post by:
Hi Could someone please advise on the best method to achieve the following. I want a flat menu which uses images rather than text for each menu item. All items will have the same image...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.