Solved

menus

Posted on 2000-03-02
2
190 Views
Last Modified: 2010-05-02
how to give icon to user created menus?
0
Comment
Question by:avbreddy
2 Comments
 
LVL 3

Expert Comment

by:jetforce
ID: 2579385
Have a look at www.VBAccelerator.com there is a control which allows you to do this and also it gives you more options. You will also find more great controls there.

Hope this helps
0
 

Accepted Solution

by:
kartono earned 5 total points
ID: 2586196
To display the picture, use the setMenuItemBitmaps (API Functions), in the following steps :
1. Take the menu handle from the form
2. Get the submenu handle.
3. Set the bitmap for the specified item
   in the position. For this sample, use
   the picture control. According to
   the MSDN, it's better to use
   monochrome


Here is the sample code

'DECLARE THE GETMENU ITEM, THIS WILL GET THE MENU HANDLE FROM YOUR FORM

Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long

'THIS FUNCTION WILL RETRIEVE THE SUBMENU OF THE SPECIFIED MENU

Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long

'API CONSTANT, WHICH SPECIFIES THE YOU WANT TO ACCESS THE SUBMENU BY POSITION

Private Const MF_BYPOSITION = &H400&

Private Sub GiveIcon
   dim mHDC as long
   dim msHDC as long
   dim pHDC as long

  'ME.HWND REFERS TO YOUR FORM HWND PROPERTY, RETURN ACTIVE MENU HANDLE
    mHDC = GetMenu(Me.hwnd)

  'GET SUBMENU FROM THE ACTIVE MENU
    msHDC = GetSubMenu(mHDC, 0)
  'GET THE HANDLE FROM PICTURE
    pHDC = myPic.Picture.Handle

  'SET THE MENU ITEM BITMAPS FOR THE
  'FIRST ITEM IN SUBMENU  
    lRet = SetMenuItemBitmaps(msHDC, 0, MF_BYPOSITION, pHDC, pHDC)

End Sub

Hope that helps

cheers

KN
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 start screen issues 9 54
String manipulation in Visual Basic 7 62
MsgBox 2 54
Access 2013 combo box not working 3 43
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…
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now