473,498 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create pictures for Menu

66 New Member
Hi, All
Is it possible to add icons in place of menu names in Menu Editor or any other way
Mar 27 '08 #1
4 3686
gobblegob
133 New Member
Hi, All
Is it possible to add icons in place of menu names in Menu Editor or any other way
Hi anuragshrivastava,
Give this a try.

this is for VB6

Add a new Module (default name)

Add this code:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Const MF_BITMAP = &H4&
  4. Public Const MIIM_ID = &H2
  5. Public Const MIIM_TYPE = &H10
  6. Public Const MFT_STRING = &H0&
  7.  
  8. Public Type MENUITEMINFO
  9.     cbSize As Long
  10.     fMask As Long
  11.     fType As Long
  12.     fState As Long
  13.     wID As Long
  14.     hSubmenu As Long
  15.     hbmpChecked As Long
  16.     hbmpUnchecked As Long
  17.     dwItemData As Long
  18.     dwTypeData As String
  19.     cch As Long
  20. End Type
  21.  
  22. Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
  23. Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" (ByVal hMenu As Long, ByVal un As Long, ByVal b As Boolean, lpMenuItemInfo As MENUITEMINFO) As Boolean
  24. Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
  25. Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
  26. Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
  27. 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
================================================== =====

On the Form add these menu's.....
mnuFile
mnuOpen
mnuSave

also add 3 pictureboxes ( 1 and 2 with the pictures you want in the menu, 3 left blank) and set properties Visible = False


CODE: VB 6

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Form_Load()
  4. On Error GoTo err
  5.     Dim hMenu As Long, hSubmenu As Long
  6.     Dim hID As Long
  7.  
  8.     Me.Hide
  9.  
  10.     'Get the menuhandle of your app
  11.     hMenu = GetMenu(Me.hwnd)
  12.  
  13.     'Get the handle of the first submenu (Hello)
  14.     hSubmenu = GetSubMenu(hMenu, 0)
  15.  
  16.     'Get the menuId of the first entry (Bitmap)
  17.     hID = GetMenuItemID(hSubmenu, 0)
  18.  
  19.     'Add the bitmap
  20.     'You can add two bitmaps to a menuentry
  21.     'One for the checked and one for the unchecked
  22.     'state.
  23.     SetMenuItemBitmaps hMenu, hID, MF_BITMAP, Me.Picture1.Picture, Me.Picture2.Picture
  24.  
  25.     ' repop the picture box
  26.     Set Me.Picture3.Picture = LoadPicture(App.Path & "\lake.bmp")
  27.  
  28.     ' do the next submenu
  29.     hID = GetMenuItemID(hSubmenu, 1)
  30.  
  31.     ' add the bitmap
  32.     SetMenuItemBitmaps hMenu, hID, MF_BITMAP, Me.Picture3.Picture, Me.Picture3.Picture
  33.  
  34.     Me.Show
  35.     Exit Sub
  36. err:
  37.     err.Clear
  38.     Me.Show
  39. End Sub

Let us know if you have any luck with this.
GobbleGob.
Mar 27 '08 #2
anuragshrivastava64
66 New Member
Sorry sir but is there anything else i've to do
Its not working at all
Mar 27 '08 #3
gobblegob
133 New Member
Sorry sir but is there anything else i've to do
Its not working at all
What errors you getting?
Mar 27 '08 #4
jamesd0142
469 Contributor
I tried out an idea and it might help...

Use a toolstrip and dock it to the top of your form, add a button to the toolstrip and change the image... works for me...

JAmes
Mar 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
3879
by: Raymond H. | last post by:
Hello, 1- How to see, in a Label, the URL of a link that the mouse pass over? (in the WebBrower control in a vb projet). 2- How to create a menu and a submenu via a button Command1? and...
6
1782
by: Nutshell | last post by:
Hi, I created a web page which contains table. I use table cells to display a picture using <img src>. The problem is that some pictures are not being fully displayed, only a quarter of the left...
1
1374
by: Jenni | last post by:
Quick question: What is the best way to include pictures in a database. I am making one that allows folks to sort through a bunch of jpg's. The only way I can figure out is to insert an OLE object,...
1
1939
by: news.microsoft.com | last post by:
Hello and first of all thank you for your time. I am currently developing an ASP.net web page, which has data stored in SQL Server. It is a web page for a State Agent and my problem is: I need...
7
1376
by: iwdu15 | last post by:
hi, i was wondering if there was anyway to put icons/images next to menu items? thanks
6
4726
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
1
1690
by: DSchlichte | last post by:
Hello ' I need some help. I've created a little application to paint, save and load pictures (Bitmap-graphics) into ' a picturebox-object on the desktop. There's no problem to paint or to load...
2
9173
by: JT | last post by:
Okay, I've seen about 4 years' worth of posts about this with no viable solutions. I've spent 9 hours today trying to fix this. It works BEAUTIFULLY on my local IIS installation, but when I...
1
1197
by: =?Utf-8?B?bm9yZHkyMDA=?= | last post by:
The first bunch of pictures I downloaded to my computer I could resize by right clicking and the drop down menu would have an item that seaid resize. I resized to a large email format, saved that...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.