Solved

Pictures in Menus

Posted on 1998-12-01
9
229 Views
Last Modified: 2010-05-03
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
Comment
Question by:heydes
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1447687
It is not Possible to add pictures to pull down menu in VB 5.0.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1447688
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
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1447689
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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 

Author Comment

by:heydes
ID: 1447690
I can't accept an answer that just tells me its impossible sorry ;/
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1447691
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
 

Accepted Solution

by:
RobS earned 260 total points
ID: 1447692
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
 
LVL 14

Expert Comment

by:waty
ID: 1447693
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
 

Author Comment

by:heydes
ID: 1447694
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
 

Expert Comment

by:RobS
ID: 1447695
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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 40
Windows 10 start screen issues 9 55
How to debug this code 7 61
How to compare ms sql hashbytes results within vb6 5 75
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

809 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