Page 2 of 2

Posted: Mon Sep 18, 2006 12:34 am
by srod
Afraid my code does a lot more than that one. Hence the difference in size! :)

Yours will set the standard menuitem bitmaps which are very inflexible and I don't think can be resized.

The code I posted will allow icons of any size, will colour menu items and so on! Slight adjustments and different menu items can be coloured differently and have different heights etc.

Posted: Mon Sep 18, 2006 3:44 am
by Joakim Christiansen
srod wrote:Afraid my code does a lot more than that one. Hence the difference in size! :)

Yours will set the standard menuitem bitmaps which are very inflexible and I don't think can be resized.

The code I posted will allow icons of any size, will colour menu items and so on! Slight adjustments and different menu items can be coloured differently and have different heights etc.
Okay, that's cool! :D

..

Posted: Mon Sep 18, 2006 6:21 pm
by NoahPhense
Very nice code srod!

Like to see more if this type of work.

- np

Posted: Tue Mar 06, 2007 1:31 pm
by Derek
Just messing with menu's and tried this out but for some reason LoadImage_() is always returning a null, anyone know why, I'm assuming that the code is loading a system icon but I don't know from where?

Using xp home sp2, but I doubt if that is the problem.

Posted: Tue Mar 06, 2007 1:55 pm
by srod
Derek, the two load image commands in the example code are loading two external icons; 'open.ico' and 'save.ico'.

If you're going to use this particular example, then you need to switch these icons for two of your own, i.e. two lying around your hard drive! Just replace my two icons with the full path/name of your own.

In proper applications I shove all icons in the resource section of the exe etc.

Posted: Tue Mar 06, 2007 2:29 pm
by Derek
Ah, I see. I went looking for the ico files but couldn't find them and assumed they were in another file and that the system had access to them.

Thanks for clearing that up.

I really should read more about api calls. :)

Posted: Sun Feb 10, 2008 8:24 am
by superadnim
Wonderful code there :)

I've a question: how do you draw the separation lines?, because they are not owner-drawn in your example, right?. I'd like to draw them as well so I can make them match my menu color but I don't really know where to look at to begin with.

In fact I'm getting a headache :P

Posted: Sun Feb 10, 2008 5:15 pm
by srod
I haven't looked at the code for a while but I seemed to recall only drawing the command items rather than all aspects of the menus etc. This is something which I should rectify, but the truth is that I no longer use this code etc. I use an external menu library instead.

If you wish to ownerdraw the separators then you'll need to change the line :

Code: Select all

ModifyMenu_(GetMenu_(hWnd),item,#MF_BYCOMMAND|#MF_OWNERDRAW,item,icon) 
to

Code: Select all

ModifyMenu_(GetMenu_(hWnd),item,#MF_BYREFERENCE|#MF_OWNERDRAW,item,icon) 
and then make sure that for each menu item, the 'item' value passed to the AddMenuIcon() function is the positional index and the command index etc. (See the api guide for an explanation of this).

Once this is done you will receive #WM_MEASUREITEM and #WM_DRAWITEM messages for separators as well as comand items etc.

Re: Menu Icons

Posted: Tue Jan 12, 2010 1:42 am
by skywalk
Hi,
Any way to right justify the last main menu item?
Most often, this is the Help menu.
I am trying to preserve the look and feel of my VB6 apps which followed this convention.
The VB6 code manipulates the menu at form load event by calling API functions "Get and SetMenuItemInfo".
I am too new a user to verify even where to begin doing this.