Solved

Pictures in Menus

Posted on 1998-12-01
9
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month4 days, 7 hours left to enroll

635 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