Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Display menu-bitmaps with 16 or more colors

Posted on 1998-09-06
3
Medium Priority
?
233 Views
Last Modified: 2010-05-18
The question is simple: How do you display menu bitmaps with 16 or more colors. I want to have both a bitmap and a text, and I want to be able to display bitmaps with a size of 16x16. I know that the size can be different on different computers, but programs like ICQ, MS Word and more have done it, so why can't I?
0
Comment
Question by:boivie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
ronit051397 earned 450 total points
ID: 1338765
From Chami's Tips (http://www.chami.com/tips/delphi/010597D.html):

Have you been envious of the Windows 95 Start Menu, because of the way it's able to display bitmaps on its menu items? Well, it's not too hard to add small bitmaps to your menu items by using the following function:

              procedure AddBitmapToMenuItem(
                PopupMenu : TPopupMenu;
                nItemPos  : integer;
                Bitmap    : TBitmap );
              begin
                SetMenuItemBitmaps(
                  PopupMenu.Handle,
                  nItemPos,
                  MF_BYPOSITION,
                  Bitmap.Handle,
                  Bitmap.Handle );
              end;

The Windows API function "SetMenuItemBitmaps()" is mostly used to set bitmaps for
"checkable" menu items -- menu items with two bitmaps for checked and unchecked
states. To keep the "AddBitmapToMenuItem()" function simple, we're not changing
menu item's size according to the size of the bitmap. This means, you can only pass
bitmaps that are small enough to fit in the default size of your menu items.

To keep the bitmaps for your menu items built into your application:

Drop a "TImage" component on your form.
Assign a bitmap of your choice to the "Picture" property of the newly created "TImage" component.
Call "AddBitmapToMenuItem()" function as follows from your "FormCreate()"
event (assuming that the pop-up menu that you're assigning the bitmap to is named "PopupMenu1," the image component you're using is named "Image1,"
and the position of the actual menu item you want to set the bitmap on is 0 --
                   1st item = 0, 2nd item = 1, 3rd item = 2, etc.):

                   AddBitmapToMenuItem(
                     PopupMenu1,
                     0,
                     Image1.Picture.Bitmap );

              To load the menu item bitmaps at the run-time:

                   procedure TForm1.
                     FormCreate(Sender: TObject);
                   var
                     BMP : TBitmap;
                   begin
                     BMP := TBitmap.Create;
                     BMP.LoadFromFile(
                       'MyBitmap.BMP' );
                     AddBitmapToMenuItem(
                       PopupMenu1, 0, BMP );
                   end;
               
0
 

Author Comment

by:boivie
ID: 1338766
Thanks for the answer, but I'm still having two problems: 1: All colors of the bitmap (16 colors) don't work and 2: The size is different on different computers. The bimaps' size is 16x16 but a few computers only display the top-left 10x10. Do you know how to fix this too?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1338767
Download the RX Components, they have a component with source:
http://rx.demo.ru/files/index.html


0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question