2 Attachment(s)
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?
Attachment 184771
Thank you!
Attachment 184770
Code:
Option Explicit
Private Sub mnu1_Click()
Dim b As Boolean
b = Me.mnu1.Checked
b = Not b
Me.mnu1.Checked = b
End Sub
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.
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.
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
Re: Setting submenu item Checked results in error 387
Tip: post the test project.
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.
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).