Results 1 to 10 of 10

Thread: XP Smart Menu - Adding icons

  1. #1

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    XP Smart Menu - Adding icons

    THIS EXAMPLE I MADE SHOWS YOU HOW TO ADD ICONS EVEN EASIER. USING AN IMAGE CONTROL

    FIRST WE MAKE THE SUB, IT TELLS US WHERE THE IMAGE LIST IS AND EXTRACTS THE ICONS

    VB Code:
    1. Option Explicit
    2.  
    3. Private Function pGetPicture(sFileName As String) As StdPicture
    4.    Dim c As Long
    5.    
    6.     For c = 1 To frmMain.imlMain.ListImages.Count
    7.         If LCase(frmMain.imlMain.ListImages(c).Key) = LCase(sFileName) Then
    8.             Set pGetPicture = frmMain.imlMain.ListImages(c).ExtractIcon
    9.         End If
    10.     Next
    11.    
    12.   End Function

    NOW WE BUILD THE MENU, HERE IS A COPIED PART OF MY PROJECT

    VB Code:
    1. Public Sub BuildMainMenu()
    2.     With frmMain.mnuMain.MenuItems
    3.    
    4.         .Add 0, "KeyFile", , "&File"
    5.         .Add "KeyFile", "KeyExit", , "E&xit", pGetPicture("EXIT"), vbAltMask, vbKeyQ
    6.  
    7.     End With
    8. End Sub

    HOPE THIS WAS USEFUL, ITS MUCH BETTER THAN USING RESOURCE FILES!

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: XP Smart Menu - Adding icons

    Originally posted by Madboy
    HOPE THIS WAS USEFUL, ITS MUCH BETTER THAN USING RESOURCE FILES!
    Why?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Because,

    a) the way i used resource files, made the icons appearance slightly dodgee

    b) you dont have to mess about adding them to the resource file

    c) You dont need a huge module like i did just to load the icons

    d) Resource Hacker cant view your icons as they are stored internally into a Image List

    e) The compiled file size is slightly less, no big difference.

    f) Resource Editor is fussy when loading icons, they have to be a falid format or they wont load.


    Does that conclude my original post

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Yep


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Good

  6. #6
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    I changed your function to use the Index integer value instead, I find it a lot easier to use =) :

    VB Code:
    1. Private Function pGetPicture(iIndex As Integer) As StdPicture
    2.    Dim c As Long
    3.         For c = 1 To frmMain.imlMain.ListImages.Count
    4.         If LCase(frmMain.imlMain.ListImages(c).Index) = LCase(iIndex) Then
    5.             Set pGetPicture = frmMain.imlMain.ListImages(c).ExtractIcon
    6.         End If
    7.     Next
    8.       End Function
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  7. #7

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Ah, ok cheers

    Do you use the XP Smart Menu?

  8. #8
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Not often, but yes, sometimes I do - mostly to spice up the boring interfaces I make =).
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  9. #9
    Addicted Member
    Join Date
    Oct 2004
    Location
    Philippines
    Posts
    149

    Re: XP Smart Menu - Adding icons

    Can you post a sample program? I always get a method or data not found on the ".menuItems" part. . Newbie here

  10. #10

    Thread Starter
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253

    Re: XP Smart Menu - Adding icons

    Well im no longer a VB programmer, but maybe someone else could help you?

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