Results 1 to 9 of 9

Thread: Icons on the menu bar?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313

    Question

    You know on programs like word, and excel you click File or hit alt+F and you will see next to new a little sheet of paper thingy, and next to open you see a folder. How do you put thos pics in?

  2. #2
    Guest
    Take a look at this example.

    Still need more? Search www.planet-source-code.com for "Menu Icons".

  3. #3
    Guest
    Code:
    Public Declare Function GetMenu Lib "user32" _
    (ByVal hwnd As Long) As Long
    
    Public Declare Function GetSubMenu Lib "user32" _
    (ByVal hMenu As Long, ByVal nPos As Long) As Long
    
    Public Declare Function GetMenuItemID Lib "user32" _
    (ByVal hMenu As Long, ByVal nPos As Long) As Long
    
    Public 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
    
    Function Pic_Menu(HdcPicC As Long, HdcPicUnC As Long)
      Dim lngMenu As Long
      Dim lngSubMenu As Long
      Dim lngMenuItemID As Long
      Dim lngRet As Long
    
      lngMenu = GetMenu(Form1.hwnd)
    
      lngSubMenu = GetSubMenu(lngMenu, 0)
    
      lngMenuItemID = GetMenuItemID(lngSubMenu, 2)
    
      lngRet = SetMenuItemBitmaps(lngMenu, lngMenuItemID, 0, _
        Picture1.Picture, Picture1.Picture)
    End Function
    This example supports only 13x13 bitmaps.

  4. #4
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    If you make menus with a couple of classes I've made, you can have menus that are exactly like the VB menus

    I'm e-mailing it to you now...
    Courgettes.

  5. #5
    Guest
    Code:
    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 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
    Const MF_BITMAP = &H4&
    
    Private Sub Command1_Click()
    
        Dim hMenu As Long, hSub As Long, ItemID As Long
        hMenu = GetMenu(Me.hwnd)
        hSub = GetSubMenu(hMenu, 0)
        ItemID = GetMenuItemID(hSub, 0)
        SetMenuItemBitmaps hMenu, ItemID, MF_BITMAP, Picture1.Picture, Picture1.Picture
    
    End Sub

  6. #6
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Just a quick question about the code above .
    When I use it my Icons seem to lose they're transparency .
    I mean I have an icon with a transparent background , but
    when it loads up into the menu it gets sort of discolored . How can I avoid that ?

    []P
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I think you have to use 4 bit colors
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    258
    Ouch!!!! ok thanks for the idea . Is there away around this ?
    Visual Basic 6 SP4 on win98se

    QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm sure there is (look at all the menus in some apps), but nobody seems to know
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width