Results 1 to 7 of 7

Thread: Setting submenu item Checked results in error 387

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Question Setting submenu item Checked results in error 387

    Hello!

    I have a menu with an item ("mnu1") which has a submenu ("mnu1_b")

    Before I added the submenu, all was fine.

    Now, after adding the submenu, I can no longer set the item checked.

    Error 387 is raised: "Checked property can not be set for this control element.

    The error is raised when I just hover over "mnu1". The hovering seems to results in a click which then calls the click code stated below. However, I don't see what's wrong with my code.

    What am I missing here?

    Here is a better example: I have photoshopped it. It's not possible. When I try to set the check in the menu editor, VB6 says "Setting this menu item to Checked is not possible".
    But why, and what are would be an alternative?

    Name:  not possible1.png
Views: 1175
Size:  7.6 KB

    Thank you!

    Name:  err1.jpg
Views: 1547
Size:  21.7 KB

    Code:
    Option Explicit
    
    Private Sub mnu1_Click()
    
        Dim b As Boolean
        b = Me.mnu1.Checked
        
        b = Not b
        
        Me.mnu1.Checked = b
        
    End Sub
    Last edited by tmighty2; May 5th, 2022 at 08:42 AM.

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

    Re: Setting submenu item Checked results in error 387

    To me, it looks like you're trying to set a sub-menu container as checked, and not an actual menu item.
    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2017
    Posts
    761

    Re: Setting submenu item Checked results in error 387

    I have edited my post and showed what I actually wanted to do. As it seems I actually try to check a submenu container, but I don't see what's wrong about that.

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    5,262

    Re: Setting submenu item Checked results in error 387

    IIUC, the moment he checks to invite his drunk uncle, that there is also a checkmark at "invite family".
    the same the other way round:
    the moment he unchecks the last Family-member in his sub-menu (and UNINVITING your mother-in-law is never wrong!),
    that the checkmark to invite family-members disappears
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  5. #5
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,671

    Re: Setting submenu item Checked results in error 387

    Tip: post the test project.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Setting submenu item Checked results in error 387

    The 387 is a long-standing bug. The exception thrown should probably be a 380 "Invalid property value" instead.

    But in any case you are attempting an illegal operation. The "Checked" property only applies to menu items, not menu groups. That's because selection has a different meaning for groups vs. items and "Checked" gets toggled via item selection.

    I'm sure you can find programs with a broken non-standard UI that appear to do as you wish here. But these almost certainly are manually fiddling with menu bitmaps to simulate checking on a group. I have no idea how the user is expected to interact with such broken messes.

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

    Re: Setting submenu item Checked results in error 387

    In theory, I suppose it would make sense if you could work out a "Checked", "Gray Checked", & "Unchecked" option, with "Gray Checked" meaning partially checked items. And then checking (or unchecking) the group would check (or uncheck) all the sub-items.

    But, I've never seen it, and it's definitely going to take some API work to get it done (if it's possible at all).
    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.

Tags for this Thread

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