SetMenuItemBitmaps parameters...

Hi!

let me ask a pretty silly question.
What are the parameters for SetMenuItemBitmaps????

I know which they are and have read the documentation in win32.hlp but waht I mean is what are they?

hMenu : Integer
for example is it the handle to the mainmenu or the specific menu item I want to assign a bitmap to?

and the following two paramets
what should they be if I want to
assign the bitmap to the menuitem with menuindex = 4?

And finally the bitmap handle.
Can I us e both bitmap and icon
handles?
or just bitmap.handle????

please enlighten me...

tnx on advance
\Dr. Gonzo
dr_gonzoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Hi Gonza,

from my view the parameters are quite unique.

hMenu is the handle to the menu to which the item belongs (might be a submenu)

For changing item with index 4 (assuming zero based indexing) you'd pass 4 and MF_BYPOSITION in the next two parameters.

The last two parameters clearly tell you they expect HBITMAPS not HICON, so you only can pass bitmap handles not icon handles.

Ciao, Mike
0
intheCommented:
see an example here at this fantastic website:

http://inthe.future.easyspace.com/delphi/addmenu.html

;-)
0
dr_gonzoAuthor Commented:
hmmm. Something really fishy with my code.
inthe: I run the code you linked to. And it works very nice with the system menu. I think my problem is the handle of my menu.
-----------

If I have a TMainMenu.
Wouldn't the handle be myMainMenu.Handle
???

Look at my source below.
Look at the trhee diffrent assigns of myHandle. Why does it only work with the one that is not commented out?

I want to set a bitmap to the first item in my main menu. Why doesn't it work???

procedure TForm1.FormCreate(Sender: Object);
var
myBmp            : TPicture;
myHandle      : Integer;

begin
   myBmp := TPicture.Create;
   myBmp.LoadFromFile('c:\test.bmp');
   myHandle := Windows.GetSystemMenu(Handle, False);
   //myHandle := Main1.Handle
   //myHandle := Windows.GetMenu(Handle);
   SetMenuItemBitmaps(myHandle, 0, MF_BYPOSITION, myBmp.Bitmap.Handle, myBmp.Bitmap.Handle);
   DrawMenuBar(Handle);
end;

tnx for the help sofar.
\Dr. Gonzo
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

LischkeCommented:
Hi Gonzo,

perhaps at this time your menu handle isn't created yet? Try assigning the bitmap in a button click handler. If that works that my assumption is true else there must be another problem.

Ciao, Mike
0
intheCommented:
i put some comments i hope you follow you need to reference the item[0] etc for the correct handle.

try this instead:

procedure TForm1.FormCreate(Sender: TObject);
var
myBmp : TPicture;
myHandle : Hmenu;
begin
   myBmp := TPicture.Create;
   myBmp.LoadFromFile('c:\test.bmp');
   myHandle := Mainmenu1.Items[0].Handle;
  { the  0 in above is the first mainmenuitem}
   SetMenuItemBitmaps(myHandle, 0, MF_BYPOSITION, myBmp.Bitmap.Handle, myBmp.Bitmap.Handle);
  {the 0 in this above is the first item in first mainmenuitem
    changed to a 1 would be second item in first mainmenuitem
     SetMenuItemBitmaps(myHandle, 1, MF_BYPOSITION, myBmp.Bitmap.Handle, myBmp.Bitmap.Handle);}
   DrawMenuBar(Handle);
end;


Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intheCommented:
did you try it ?
0
dr_gonzoAuthor Commented:
Yeah sure I tried it!

I even thought I had given you the points already but EE's database don't seem to remeber what happened during the weekend :-)

I said I'd give you the points, but that I wanted to keep the question open so I could also understand the code.

It was hard to se why
MainMenu.Items[0].Handle
wasn't the same thing as
Item1.Handle

When Item1 was MainMenu's first item...

It all came clear to me anyway so I don't need to ask it anymore :-)

tnx for the help

regards,
Dr. Gonzo
0
intheCommented:
ok :-)
and yes it is a bit confusing at first.
0
LischkeCommented:
Gonzo, thank you for totally ignoring me. I actually answered most of your original question...
0
dr_gonzoAuthor Commented:
Lischke:
Sorr actually I wasn't ignoring you. I wrote two mesages during the weekend but none of them shows up here today. And when I wrote the last time I was in a bite of a hurry.
Anyway: Your answer didn't take me were I wanted to go.
My code does follow all your tips and ideas of what code be wrong.

What was actually wrong was that the handle to use is suppost to be
something else than one could expect if one didn't use the brain the hole way out.

What made me understand what I was doing wrong was the code from Inthe.
And I have to give the points to the one that solved my problem, not the one that answered first.

Anyway wasn't my meaning to ignore your answer. No hard feelings I hope...

regards,
Dr. Gonzo
0
LischkeCommented:
Hi Dr. Gonzo,

I agree, the points should go to the one who actually solved the problem. Only one conflict remains, though. What about the one who answers your question? The first (Barry) and the latter (me) are different persons...

I don't want that you offer now additional points. All I request that you think about the discussion here and draw your consequences.

Ciao, Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.