Page 1 of 2 12 LastLast
Results 1 to 40 of 56

Thread: Menu Icons

  1. #1

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Menu Icons

    This is interesting to me.. I know you can have menu and sub menu icons. However, Based on the menu item it will have an icon that you are currently viewing. I'll have to come up with a screenshot of what I mean. This is interesting to me tho. I just figured I would throw it out there as an idea.
    Last edited by Mongoose_MHS; May 19th, 2024 at 03:50 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  2. #2

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Like.. If you have a menu that has a few options and select one.. then go back to select another option, it will have an icon infront of the one currently being used or displayed. Not just an icon for every option just 1 for the current if anyone knows what I mean. Like a checkmark or a dot.
    Last edited by Mongoose_MHS; May 14th, 2024 at 08:24 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  3. #3
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: Menu Icons

    Menus support having a checkmark there. You don't even need API; just the basic VB menus have a .Checked property.

  4. #4

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Cool, but can you have it so that only the current menu has a checkmark? So, if you click one item it will have it and if you select another item it will have it instead?

    I came across this and it seems cool.. However, I am sure there is a way to do it with coding:
    http://www.vbaccelerator.com/home/VB...l/article.html
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  5. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,849

    Re: Menu Icons

    The concept is simple enough. Handle the click event of the menu items and inside the event handler check if the menu item is checked. If it is then loop over every other menu item to uncheck the currently iterated control.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,267

    Re: Menu Icons

    Mongoose, it's entirely up to you how you handle a menu item's "checked" property, or which menu items put a checkmark on which other menu items. This is all standard VB6 menu stuff, no APIs no nothing but the standard properties.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: Menu Icons

    Quote Originally Posted by Mongoose_MHS View Post
    Cool, but can you have it so that only the current menu has a checkmark? So, if you click one item it will have it and if you select another item it will have it instead?
    Easy. Example with a submenu array.

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            If c = Index Then
                Submenu1(c).Checked = True
            Else
                Submenu1(c).Checked = False
            End If
        Next
    End Sub
    Attached Files Attached Files

  8. #8
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,849

    Re: Menu Icons

    Quote Originally Posted by Eduardo- View Post
    Easy. Example with a submenu array.
    Does VB6 offer a CheckOnClick property? If so then all you’d need to do is check if it doesn’t equal the index.

    My VB6 experience is limited so I wasn’t sure if that’s an option or not.

    Edit - I guess you’d still need to do the equality check if you wanted to force one menu item checked at all time.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  9. #9
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: Menu Icons

    Quote Originally Posted by dday9 View Post
    Does VB6 offer a CheckOnClick property? If so then all you’d need to do is check if it doesn’t equal the index.

    My VB6 experience is limited so I wasn’t sure if that’s an option or not.
    No


    Quote Originally Posted by dday9 View Post
    Edit - I guess you’d still need to do the equality check if you wanted to force one menu item checked at all time.
    Or just this:

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            Submenu1(c).Checked = c = Index
        Next
    End Sub

  10. #10

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Ok, so I gave it a whirl and i think it's a success! Granted it's probably NOT the right way of doing it.. However, I did manage to accomplish it.. So, hence my very first project! YAY!

    I used a "shape" and "fill color".. You can make the shape visible OR hide it off the form.. But, hey it works!
    Attached Files Attached Files
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  11. #11

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Quote Originally Posted by Eduardo- View Post
    Easy. Example with a submenu array.

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            If c = Index Then
                Submenu1(c).Checked = True
            Else
                Submenu1(c).Checked = False
            End If
        Next
    End Sub
    Awesome! His code works a lot better than mine and a lot shorter.. Well, I gave it a shot and it worked but definately not as good as his.. However, I did make something work.. That's worth "something", I think. I learned to add a sound tho! That's a plus!
    Last edited by Mongoose_MHS; May 15th, 2024 at 06:16 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  12. #12

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    @Eduardo

    I do have a question tho for you.. Is it possible to carry that setting to another form that has the same exact menu options. The reason is not to unload the other form to revert back to the first form. I hope that makes sense. Cause if I close one form to open another form with the same menu, I don't want to exit out from the second form to go back to the first form. I hope that makes sense. If not i'll try to make it more understandable.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  13. #13
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: Menu Icons

    Assuming that both submenus have the same number of options:

    Code:
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            Form2.Submenu1(c).Checked = Submenu1(c).Checked
        Next
    (I hope I understood the question correctly).

  14. #14

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Yes they do. Thank you!
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  15. #15

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    @Eduardo

    Are you referring to something like this:

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            If c = Index Then
                Submenu1(c).Checked = True
                Form2.Submenu1(c).Checked = Submenu1(c).Checked 'Added
            Else
                Submenu1(c).Checked = False
    
            End If
        Next
    End Sub
    or

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            If c = Index Then
                Submenu1(c).Checked = True
                Form2.Submenu1(c).Checked = Submenu1(c).Checked 'Added
            Else
                Form2.Submenu1(c).Checked = Submenu(c).unchecked 'Just a thought
            End If
        Next
    End Sub
    If I am assuming wrong, can you please add another form in the zip so I can see it being done?
    Last edited by Mongoose_MHS; May 15th, 2024 at 06:42 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  16. #16
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: Menu Icons

    There is no property "unchecked".

    Just do this (simpler):

    Code:
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            Submenu1(c).Checked = (Index = c)
            Form2.Submenu1(c).Checked = Submenu1(c).Checked
        Next
    End Sub

  17. #17

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Adjusted, and it works so far.. Now, I have to do the samething to form2..

    Code:
    Option Explicit
    
    Private Sub Submenu1_Click(Index As Integer)
        Dim c As Long
        
        For c = 0 To Submenu1.UBound
            Submenu1(c).Checked = (Index = c)
            Form2.Submenu1(c).Checked = Submenu1(c).Checked
        Next
        Unload Me 'Added
        Form2.Show vbModal 'Added
    End Sub


    Edit: Works perfectly fine in both forms.. Thank you Eduardo!
    Last edited by Mongoose_MHS; May 15th, 2024 at 07:45 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  18. #18

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Now, I don't know if it's just me and my PC as to why there is a blue bgcolor with checkmark.. When i though it would be just the checkmark. I can deal with it.. Just curious as to why there is a blue bg to it.
    Attached Images Attached Images  
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  19. #19
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: Menu Icons

    It must be Windows theme (visual style).
    I don't see that here in Windows 11.

  20. #20

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Ahh, I am using windows 10
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  21. #21
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,849

    Re: Menu Icons

    I think that is controlled by Settings > Personalization > Colors > Window Colors.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  22. #22

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    Actually, I want to extend this even further.. So, I can CAN have what is done above.. However, now I want to try to have BOTH the main selection AND a SUB menu selection.. BOTH having the checkmark.. I am currently working on that. If you can beat me to it as I am new.. go for it cause I would love to see this in action. Again, I am currently working on it but I don't know how far I'll get at my pace.

    I would post a pic, but obviously I haven't gotten that far yet.. If I get there I will tho. and I wanted a "simple" project for school... So much for that lol
    Last edited by Mongoose_MHS; May 16th, 2024 at 06:34 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  23. #23

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    I think it can't be done to have a Submenu AND a SubSubMenu checked cause I the Submenu is not being checked - It just opens to the SubSubmenu.. I gave it a shot. The reason I wanted to try this is because I wanted to see which Submenu I'm in and then open the SubSubmenu to see which one I was on. Oh well, so much for that.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  24. #24

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    @Eduardo

    Ok, so what I wanted to do was have BOTH submenu AND subsubmenu checked, However, I realized that the "Submenu" cannot be "checked". I have tried. So, I am asking if there is a way to have both with a checkmark? Or is that a no go?
    Attached Images Attached Images  
    Last edited by Mongoose_MHS; May 18th, 2024 at 09:32 PM. Reason: spelling
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  25. #25
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,132

    Re: [RESOLVED] - Menu Icons

    Unfortunately VB6 only allows to set the Checked property in lowest level menus.

  26. #26
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: [RESOLVED] - Menu Icons

    That's just a limitation of VB6, not menus themselves, if you wanted to pursue managing it by API with CheckMenuItem.

    Name:  mnucheck.jpg
Views: 107
Size:  27.6 KB

    For example, to check the first subitem of the first menu like in the picture;

    Code:
    Option Explicit
    Private Enum LongPtr
        vbNullPtr
    End Enum
    Private Enum MenuFlags
      MF_INSERT = &H0
      MF_ENABLED = &H0
      MF_UNCHECKED = &H0
      MF_BYCOMMAND = &H0
      MF_STRING = &H0
      MF_UNHILITE = &H0
      MF_GRAYED = &H1
      MF_DISABLED = &H2
      MF_BITMAP = &H4
      MF_CHECKED = &H8
      MF_POPUP = &H10
      MF_MENUBARBREAK = &H20
      MF_MENUBREAK = &H40
      MF_HILITE = &H80
      MF_CHANGE = &H80
      MF_END = &H80                    ' Obsolete -- only used by old RES files
      MF_APPEND = &H100
      MF_OWNERDRAW = &H100
      MF_DELETE = &H200
      MF_USECHECKBITMAPS = &H200
      MF_BYPOSITION = &H400
      MF_SEPARATOR = &H800
      MF_REMOVE = &H1000
      MF_DEFAULT = &H1000
      MF_SYSMENU = &H2000
      MF_HELP = &H4000
      MF_RIGHTJUSTIFY = &H4000
      MF_MOUSESELECT = &H8000&
    End Enum
    Private Declare Function CheckMenuItem Lib "user32" (ByVal hMenu As LongPtr, ByVal uIDCheckItem As Long, ByVal uCheck As MenuFlags) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As LongPtr, ByVal nPos As Long) As LongPtr
    Private Declare Function GetMenu Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
    
    
    Private Sub Form_Load()
    Dim hMenu As LongPtr
    Dim hSubmenu As LongPtr
    hMenu = GetMenu(Me.hWnd)
    hSubmenu = GetSubMenu(hMenu, 0)
    CheckMenuItem hSubmenu, 0, MF_BYPOSITION Or MF_CHECKED
    End Sub
    Note that this is outside of VB's knowledge; it won't changed the .Checked property because VB doesn't know you've made the change from outside. So if you're doing it this way to reliably determine whether it's checked, you'd also have to use API...

    Private Declare Function GetMenuState Lib "user32" (ByVal hMenu As LongPtr, ByVal uID As Long, ByVal uFlags As MenuFlags) As Long
    If GetMenuState(hSubmenu, 0, MF_BYPOSITION) And MF_CHECKED Then

    (it's checked)
    Last edited by fafalone; May 19th, 2024 at 02:12 AM.

  27. #27

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    I would have to a working example..
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  28. #28
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: [RESOLVED] - Menu Icons

    I gave you one. I even included all the declares for you. Just copy/paste the code I posted into Form2 from the picture you made post #24.

  29. #29

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    K, but...

    Quote Originally Posted by fafalone View Post

    Note that this is outside of VB's knowledge; it won't changed the .Checked property because VB doesn't know you've made the change from outside. So if you're doing it this way to reliably determine whether it's checked, you'd also have to use API...

    Code:
    Private Declare Function GetMenuState Lib "user32" (ByVal hMenu As LongPtr, ByVal uID As Long, ByVal uFlags As MenuFlags) As Long
    If GetMenuState(hSubmenu, 0, MF_BYPOSITION) And MF_CHECKED Then 'You stopped here, so how can I uise it if the statement is not complete?
    (it's checked)
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  30. #30

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    NVM, I got it.. I had to delete some code I had..

    *I see how this is working out.. Lengthy process. However, I think it will work out just fine. Let me work on this a bit and I'll post up a zip when I'm finish. Give me some time, as I do not sit at my PC for long periods of time in one sitting.
    Last edited by Mongoose_MHS; May 19th, 2024 at 02:24 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  31. #31

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: [RESOLVED] - Menu Icons

    @ fafalone

    Ok, I "thought" I had this figured out.. Somehow I don't.. So, the first submenu works with it's subsubmenu's.. the other subsubmenu's do too.. However, the 1st submenu stays checked and not the other 2.. Can you have a look and tell me what I am missing as I just can't forsee it.
    Attached Files Attached Files
    Last edited by Mongoose_MHS; May 19th, 2024 at 03:44 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  32. #32
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: Menu Icons

    I'm having trouble following what you're even trying to do there... you've got two separate forms with their menus jumbled together.

    But which one are you talking about stays checked? The one set by API? There's no code I can see even attempting to determine which of "Sub Menu 1" "Sub Menu 2" or "Sub Menu 3" is checked; just the code I wrote that checks "Sub Menu 1"; it's not looking up what's checked. You'd change it to CheckMenuItem hSubmenu, 1, MF_BYPOSITION Or MF_CHECKED to check "Sub Menu 2" instead, and CheckMenuItem hSubmenu, 2, MF_BYPOSITION Or MF_CHECKED to check "Sub Menu 3".

    One problem I see you're going to run into with trying is on Form2 you have mnuSubMenu(0), mnuSubMenu1(1), and mnuSubMenu2(2); I think that's just an unintentional error because you've set up the sub-sub-menu control arrays right and the sub-menus on Form1 right.

  33. #33

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Well.. for form 2

    SubMenu 'this has to stay blank - this stays checked in form 2 'this one is the only one that stays checked
    ...SubSubMenu 0 'and stays checked 'works fine
    ...SubSubMenu 1 'and stays checked 'works fine
    Submenu1 'this has to have a number to differ - this DOESN'T stay checked in form 2 why?
    ...SubSubMenu0 'and stays checked works fine
    ...SubSubmenu1 'and stays cheked 'works fine
    Submenu2 'this has to have a number to differ this has to have a number to differ - this DOESN'T stay checked in form 2 WHY?
    ...SubSubMenu 0 'and stays checked works fine
    ...SubSubmenu 1 'and stays checked works fine


    You have the code to see the menu editor.. but something like that as I am just typing freehanded..... This is what i'm trying to figure out..
    Last edited by Mongoose_MHS; May 19th, 2024 at 04:48 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  34. #34

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    It's the SUBMENUS (2 and 3) that don't stay checked, always the first one... all the SUBSUBMENUS work just fine... why is the 1st SUBMENU always checked and not the other 2 is my question..


    *Menus on both forms SHOULD be identical as you are NOT reverting back to form 1.. so form 2 will continue with choices. Form1 is just a starting point.. You "can revert back to it later, but once form2 loads.. it will handle selections. and "IF" you do revert back to form1.. then back to start on selections.
    Last edited by Mongoose_MHS; May 19th, 2024 at 04:54 PM.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  35. #35
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: Menu Icons

    Stays (or doesn't) when what happens? You set the check states once from Form1 then unload it; there's no code to change check states in Form2. If I change the API to check "Sub Menu 2" instead, it stays checks no matter what I click. So doesn't stay checked when.... what?

  36. #36

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    #34 - you posted at the same as me..

    *Menus on both forms SHOULD be identical as you are NOT reverting back to form 1.. so form 2 will continue with choices. Form1 is just a starting point.. You "can revert back to it later, but once form2 loads.. it will handle selections. and "IF" you do revert back to form1.. then back to start on selections.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  37. #37
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: Menu Icons

    Quote Originally Posted by Mongoose_MHS View Post
    It's the SUBMENUS (2 and 3) that don't stay checked, always the first one... all the SUBSUBMENUS work just fine... why is the 1st SUBMENU always checked and not the other 2 is my question..


    *Menus on both forms SHOULD be identical as you are NOT reverting back to form 1.. so form 2 will continue with choices. Form1 is just a starting point.. You "can revert back to it later, but once form2 loads.. it will handle selections. and "IF" you do revert back to form1.. then back to start on selections.
    The code example I gave you checks the first item (index 0). See the middle paragraph of post #32.

  38. #38

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    Ok,, I give up.. just too much for me and just getting aggrivated... Sometimes you just have to throw yer hands up. Thanks tho for your help.
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

  39. #39
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,010

    Re: Menu Icons

    Code:
    Private Sub CheckItemByIndex(n As Long)
    Dim hMenu As LongPtr
    Dim hSubmenu As LongPtr
    hMenu = GetMenu(Me.hWnd)
    hSubmenu = GetSubMenu(hMenu, 0)
    CheckMenuItem hSubmenu, n, MF_BYPOSITION Or MF_CHECKED
    End Sub
    CheckItemByIndex 0 - Checks "Sub Menu 1" of the Form the code is in.
    CheckItemByIndex 1 - Checks "Sub Menu 2" of the Form the code is in.
    CheckItemByIndex 2 - Checks "Sub Menu 3" of the Form the code is in.

    Code:
    Private Sub UncheckItemByIndex(n As Long)
    Dim hMenu As LongPtr
    Dim hSubmenu As LongPtr
    hMenu = GetMenu(Me.hWnd)
    hSubmenu = GetSubMenu(hMenu, 0)
    CheckMenuItem hSubmenu, n, MF_BYPOSITION Or MF_UNCHECKED
    End Sub
    UncheckItemByIndex 0 - Unchecks "Sub Menu 1" of the Form the code is in.
    UncheckItemByIndex 1 - Unchecks "Sub Menu 2" of the Form the code is in.
    UncheckItemByIndex 2 - Unchecks "Sub Menu 3" of the Form the code is in.

  40. #40

    Thread Starter
    Addicted Member Mongoose_MHS's Avatar
    Join Date
    May 2024
    Posts
    179

    Re: Menu Icons

    I'm not using "hSubMenu" and such.. You're just confusing me.. please make a working demo and point out what I did wrong in notes so I can learn... Because I have tried with failure and I really tried. Sorry, but I just don't get it. My menus are fine and match..
    Last edited by Mongoose_MHS; May 19th, 2024 at 05:43 PM. Reason: spelling
    Monroe High School.. GO HORNETS!

    If I've help you, please add to my reputation level! Each reply has a "STAR" icon followed by: "Rate this post".. click that

Page 1 of 2 12 LastLast

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