Results 1 to 4 of 4

Thread: Icons In Menus

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Gig Harbor, WA, USA
    Posts
    48

    Post

    Hey, I've become rather fond of the Office97+ Menus, that include icons by the text in the menu. I'm aware it takes quite a bit of API code, but if someone could explain how to add/modify/remove icons from menu items, I would appreciate it.

    ------------------
    (`..`->ShadowCrawler<-`..)
    Teenage Programmer
    Visual Basic, HTML, C++, JavaScript

    http://welcome.to/X12Tech
    Email: craigkovatch@compuserve.com
    ICQ#: 9872708

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    There isn't that much code to do it, here's an example:
    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
    
    Private Const MF_BITMAP = &H4&
    
    Private Sub Command1_Click()
        Dim lMenu As Long
        Dim lID As Long
        'Add Menu Bitmap
        lMenu = GetMenu(hwnd)
        lMenu = GetSubMenu(lMenu, 0)
        lID = GetMenuItemID(lMenu, 0)
        Call SetMenuItemBitmaps(lMenu, lID, MF_BITMAP, Picture1.Picture, Picture1.Picture)    
    End Sub
    
    Private Sub Command2_Click()
        Dim lMenu As Long
        Dim lID As Long
        'Remove Menu Bitmap
        lMenu = GetMenu(hwnd)
        lMenu = GetSubMenu(lMenu, 0)
        lID = GetMenuItemID(lMenu, 0)
        Call SetMenuItemBitmaps(lMenu, lID, MF_BITMAP, 0, 0)
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Gig Harbor, WA, USA
    Posts
    48

    Post

    k, i got all of that but hwnd. what hwnd do I put in? the menu's hwnd?

    ------------------
    (`..`->ShadowCrawler<-`..)
    Teenage Programmer
    Visual Basic, HTML, C++, JavaScript

    http://welcome.to/X12Tech
    Email: craigkovatch@compuserve.com
    ICQ#: 9872708

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    The Forms Hwnd, GetMenu retrieves the Menu Handle associated with the Window Handle, (Form Hwnd).

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

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