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
Solved

Pictures in Menus

Posted on 1998-12-01
9
230 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

860 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