Solved

Pictures in Menus

Posted on 1998-12-01
9
225 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
 

Author Comment

by:heydes
ID: 1447690
I can't accept an answer that just tells me its impossible sorry ;/
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

747 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

13 Experts available now in Live!

Get 1:1 Help Now