Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Icons in menu

Posted on 1999-10-10
10
Medium Priority
?
323 Views
Last Modified: 2010-05-02
Hey guys I am trying very hard to put icons in my menus but it just isn't working.  My app puts an icon in the System tray and has a popup menu come out of it when it's clicked.  I have this code I got from another question but it dosn't seem to work.

    Dim hTopMenu&, hSubMenu&, menuID&, rc&
    hTopMenu = GetMenu(Me.hwnd)
    hSubMenu = GetSubMenu(hTopMenu, 0)
    menuID = GetMenuItemID(hSubMenu, 0)
    rc = SetMenuItemBitmaps (hTopMenu, menuID, MF_BYCOMMAND, imgInfo.Picture, imgInfo.Picture)

I am running windows 95 with IE 5.0 and VB 6.0.

Thanks for any and all help.
0
Comment
Question by:Ra
[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
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 8

Expert Comment

by:vettranger
ID: 2115110
Go to :

http://www.vbaccelerator.com/

Then select the Controls menu option.

Then select Icon Menu Control.

This is a freeware control and does a very nice job.

0
 
LVL 4

Expert Comment

by:Juilette
ID: 2116099

' Remarks:
' open a new app...add a picture box and a command button
' build a menu with menu editor
' add a bitmap pic to the picture box 13 x 13
' NOT an icon...a bitmap
' if you don't want to make bitmaps there is a freeware icon extractor
' at the site below which will save Icons as bitmaps
' therefore you can use the icon once you convert it to a bitmap

' http://www.ozemail.com.au/~jaesenj/software.html
'
' this will add the pic to your menu item
'
'
'<<<<<  put his code in a bas module  >>>>>>>>>
 
Public Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Public Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

Public Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long



Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long

Public Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Boolean



Public Const MIIM_ID = &H2
Public Const MIIM_TYPE = &H10
Public Const MFT_STRING = &H0&
Public Const MF_BITMAP = &H4&

Type MENUITEMINFO
    cbSize As Long
    fMask As Long
    fType As Long
    fState As Long
    wID As Long
    hSubMenu As Long
    hbmpChecked As Long
    hbmpUnchecked As Long
    dwItemData As Long
    dwTypeData As String
    cch As Long
End Type
'
' <<<<<<<< put this code in the event you wish to use  >>>>>>>>
'
'Get the menuhandle of your app
hMenu& = GetMenu(Form1.hwnd)

'Get the handle of the first submenu (Hello)
hSubMenu& = GetSubMenu(hMenu&, 0)

'Get the menuId of the first entry (Bitmap)
hID& = GetMenuItemID(hSubMenu&, 0)

'Add the bitmap
SetMenuItemBitmaps hMenu&, hID&, MF_BITMAP, Picture1.Picture, Picture1.Picture

'You can add two bitmaps to a menuentry one for the checked and one for 'the unchecked state.

'Wayne
0
 

Author Comment

by:Ra
ID: 2116770
Sorry vettranger, but I really don't want any extra controls in this.  I want to keep the size to a minumium.

Juilette, I'll test your code later today and post a comment as to weather or not it works.  One thing I want to ask you is why only Bitmaps???  If I load all my icons into image controls at design time, what does it matter what they were?  VB will save them to the .frx file in it's own format, doesn't it?

Thanks for the quick responses guys.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:Juilette
ID: 2117169
Ra:
Can't answer that for you...I got the code off the net somewhere...I just use the icon extractor mentioned and convert them...it's not biggie for me...Your situation might be different.

Wayne
0
 

Author Comment

by:Ra
ID: 2118573
vettranger, I just checked out that control at VBAcceleator.com and it did so much stuff for me that I decided to use it.  Please repost your answer as an answer and I'll give you the points.  Sorry about the rejection before. I didn't know that control would do so much.

Thanks for the help

-------
Juilette, I couldn't get the code you gave me to work anyway. (One of the reasons I want to use the control now.)  Thanks for trying.
0
 
LVL 8

Accepted Solution

by:
vettranger earned 800 total points
ID: 2118649
Here it is, and I'm delighted that the suggested control was helpful! :-D
0
 

Author Comment

by:Ra
ID: 2121878
Thanks again vettranger, and sorry for the rejection.

To everybody that reads this and can't figure out what happened, the rejected answer is the accepted answer.  I jumped the gun and rejected it before I knew the control was so cool.  It did more then I have ever seen before, and it's free!!!!  It would take a lot of API stuff and other coding to replace it.
0
 
LVL 8

Expert Comment

by:vettranger
ID: 2121899
No problem, that's a good control but it does take a while to scope it all out! LOL
0
 
LVL 4

Expert Comment

by:Juilette
ID: 2123381
No problem, it was just a suggestion.

However, I wish people would check things out before they comment on the fact that a code doesn't work.

....FYI...the code I posted works fine...it's simply a read, cut and paste operation....no biggie!

Wayne
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6852980
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 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