Solved

Images next to a menu item using SetMenuItemBitmaps

Posted on 2001-08-16
17
469 Views
Last Modified: 2012-08-13
I have an MDI form with a menu and was attempting to place images next to some of the sub menu options.  The problem I am experiencing is the image appears to get cut off.  For example:

If I have a &Edit menu and under that I have a &Cut menu option that I want to place a picture of scissors next to it.  I Add the bmp to an imagelist and attempt to load it into the menu using the SetMenuItemBitmaps API however I only see some of the image.  Am I missing something here?  Does the image have to be a certain size?  I was using the exact bmp files for cut, copy & paste as MS does in there office products.  Any help?
0
Comment
Question by:brian_andrews
  • 6
  • 3
  • 2
  • +3
17 Comments
 
LVL 14

Expert Comment

by:wsh2
ID: 6394142
<ping>
0
 

Author Comment

by:brian_andrews
ID: 6394242
???
0
 
LVL 2

Expert Comment

by:BozzoCage
ID: 6394855
ignore wsh2 - it pings everyone (he doesn't like to buy PAQ)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:BozzoCage
ID: 6394862
well, icons certainly must be of proper size (windows doesn't resize them automatically)
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6395323
You can use this free control instead of using SetMenu: http://vbaccelerator.com/codelib/cpopmenu/article.htm
0
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6395376
Brian:

You can use the GetSystemMetrics() Win API function to get the width and height of menu bitmaps.

Add the following to a standard code module (.bas):

Public Const SM_CXMENUCHECK = 71
Public Const SM_CYMENUCHECK = 72

Public Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long


You can get the width and height (in pixels) as follows:

   Dim MenuBMPWidth  As Long
   Dim MenuBMPHeight As Long

   MenuBMPWidth = GetSystemMetrics(SM_CXMENUCHECK)
   MenuBMPHeight = GetSystemMetrics(SM_CYMENUCHECK)


Compare the results with the dimensions of your bitmaps, and you can tell whether they're bigger than the system allows.


-Dennis Borg
0
 

Author Comment

by:brian_andrews
ID: 6396939
After looking at some of the menus in, lets say the Visual Basic IDE, they are completely different than the ones that VB allows you to create.  The menus in the Visual Basic IDE allow for a much bigger picture and also are reacting to my mouse over event.
0
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6397319
>After looking at some of the menus in, lets say the
>Visual Basic IDE, they are completely different
>than the ones that VB allows you to create.  The menus in
>the Visual Basic IDE allow for a much bigger
>picture and also are reacting to my mouse over event.

To achieve those same effects, you would either need to find a 3rd party solution, or create your own owner-drawn menues.

Another effect you can achieve with owner-drawn menues is to have things such as that vertical "titlebar" on the left-hand side (or wherever) of the menu, such as the Start Menu has.

Ownerdrawn menues can be done in VB, but it's a little involved.


-Dennis Borg
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6397623
emoreau.. respectfully, in my experience, CPOPMENU is quite heavy AND buggy. Unless you are extremely technically competent I would avoid using it.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6397680
I use it since 3 years now in many applications without problems!
0
 
LVL 14

Expert Comment

by:wsh2
ID: 6397746
Calrifying the Buggy part of CPOPMENU.. it principally had to do with the dynamic Menu creation/update portions of the code.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6397774
I use it mainly for the icons part.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6449508
Please maintain:

Questions Asked 8
Last 10 Grades Given A A A A A A  
Question Grading Record 6 Answers Graded / 7 Answers Received
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6521943
Please maintain:

Questions Asked 9
Last 10 Grades Given A A A A A A A  
Question Grading Record 7 Answers Graded / 8 Answers Received
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6626531
Anybody here ?
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6767065
There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of emoreau.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.

Netminder
Community Support Moderator
Experts Exchange
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6789848
Per recommendation comment force/accepted by

Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

685 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