• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Pictures in Menus

Hey,

  I'm working in Visual Basics v5 enterprise and I wanted to know how to add pictures to a pull down menu, like in Visual Basic next to the words open or save. If you could help me out i'd be very grateful thank you.
0
heydes
Asked:
heydes
  • 4
  • 2
  • 2
  • +1
1 Solution
 
a111a111a111Commented:
It is not Possible to add pictures to pull down menu in VB 5.0.
0
 
a111a111a111Commented:
This is the answer to your question.
So before you rejecting it check if it possible at all.
my answer is no, but I am open to a new way.
0
 
a111a111a111Commented:
There are some tricky ways to simulate what you want here.

One way is to have a picture box with text in it as a replacement to the pulldown menu.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
heydesAuthor Commented:
I can't accept an answer that just tells me its impossible sorry ;/
0
 
a111a111a111Commented:
The question was: "I wanted to know how to add pictures to a pull down menu"

The answer is: You cannot do it with VB 5.0.

And one cannot fly by waving your arms.

These are facts.

Do not be sorry just accept the correct answer and continue with life.

You got the power!!!
0
 
RobSCommented:
heydes,

Copy the following code in a form.  Make sure you have a menu bar
with five options, an image list with the name img and five images, and a command button.  It should work fine; I don't think I missed anything.

- Rob


Option Explicit

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

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

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

Private Declare Function ModifyMenu Lib "user32" _
Alias "ModifyMenuA" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long, _
ByVal wIDNewItem As Long, ByVal lpString As String) As Long

Private 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

Private Declare Function GetMenuCheckMarkDimensions Lib _
"user32" () As Long

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

Private Declare Function CreateCompatibleDC Lib "gdi32" _
(ByVal hdc As Long) As Long

Private Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hdc As Long, ByVal nWidth As Long, _
ByVal nHeight As Long) As Long

Private Declare Function SelectObject Lib "gdi32" _
(ByVal hdc As Long, ByVal hObject As Long) As Long

Private Declare Function CreateBitmap Lib "gdi32" _
(ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal nPlanes As Long, ByVal nBitCount As Long, _
lpBits As Any) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function PatBlt Lib "gdi32" _
(ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal dwRop As Long) As Long

Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long

Private Sub Command1_Click()
  Dim i%
  Dim hMenu, hSubMenu, menuID, x
  hMenu = GetMenu(hwnd)
  hSubMenu = GetSubMenu(hMenu, 0) '1 for "Other" menu etcetera
  For i = 1 To 4
    menuID = GetMenuItemID(hSubMenu, i - 1)
    x = SetMenuItemBitmaps(hMenu, menuID, &H4, img.ListImages(i).Picture, img.ListImages(i).Picture)
  Next
  menuID = GetMenuItemID(hSubMenu, 5)
  x = SetMenuItemBitmaps(hMenu, menuID, 0, img.ListImages(5).Picture, 0&)

End Sub
0
 
watyCommented:
Download the following code, it does all for you, or give me your e-mail, I will send to you. Id do this all in pure VB5.

See on the following page :
http://www.geocities.com/SiliconValley/Peaks/1797

The following file :
http://www.geocities.com/SiliconValley/Peaks/1797/cpopmenud.zip
0
 
heydesAuthor Commented:
Hey thanks Rod that was exactly what i was looking for. O by the way how come the color isn't as sharp as in say vb5's pull down menu is it because it was done in a different language? O and to the kid that said it couldn't be done please stfu ;)
0
 
RobSCommented:
heydes,
   I not sure why the color isn't as sharp as in other programs (might be because of the langauge -- not sure).  Thanks for accepting my answer.

- Rob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now