Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2005, 12:46 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

Here is the code i used.....


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 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 LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long

    ' Constant for SetMenuItemBitmaps
    Private Const MF_BYPOSITION = &H400&

    ' Constant for LoadImage
    Private Const IMAGE_BITMAP = &O0
    Private Const LR_LOADFROMFILE = 16
    Private Const LR_CREATEDIBSECTION = 8192

Private Sub Form_Load()

    Dim hMenu As Long
    Dim hSubMenu As Long
    Dim hMenuImg As Long
    Dim sFileName As String

    'Get the bitmap
    sFileName = "D:\ImageMenu\35FLOPPY.BMP"
    hMenuImg = LoadImage(0, sFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or LR_CREATEDIBSECTION)
    ' Get the menu item handle
    hMenu = GetMenu(Me.hwnd)
    hSubMenu = GetSubMenu(hMenu, 0)
    ' Set the "mnuTwo" bitmap to the one that is loaded in memory
    Call SetMenuItemBitmaps(hSubMenu, 3, MF_BYPOSITION, hMenuImg, 0)

End Sub


 
Old April 26th, 2005, 03:43 AM
Authorized User
 
Join Date: Apr 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default

Hi JelfMaria!

Download this example from FreeVBCode.com: It is more thorough than the one I posted.

http://www.freevbcode.com/source/MenuTools.zip

 
Old April 26th, 2005, 03:59 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

Dim oImages As MenuImage
           i am getting error user defined type not defined here.


what reference i need to select here.........

 
Old April 26th, 2005, 04:09 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

Thanks Yaar
  I got it. Image menu was a class module which i added using add module option.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
sub menus matshediso HTML Code Clinic 2 January 31st, 2005 05:15 AM
Javascript menus alancdude Javascript 5 November 26th, 2003 11:58 AM
sliding menus Adam H-W Javascript 3 November 18th, 2003 09:38 AM
Menus Frank Schmuck BOOK: Beginning ASP.NET 1.0 1 June 6th, 2003 01:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.