Thanks, and sorry for the long post now but please stay with me ... as surely there must be a more straight forward approach than custom handling each and every possible command for the sake of just hiding the command item "hosting" that command.
Let me repeat what I want to do: when opening a document in read-only mode most of commands/command items will be offline/disabled (done by the pxv_control itself). I want to remove/hide all those items from the end user (but also show when needed).
Now, for the sake of simplicity, say we are targeting the BookmarsView pane. My initial idea was: once a document is loaded (since the BookmarksView pane is per document) iterate over all command panes -> command lines -> command bars -> command item boxes and finally -> command items "holding" commands. Hide the command item I do not want to be visible. Done.
Yes, there are at least three types of "ui elements" hosting commands in BookmarsView: right-click context menu (it is regenerated so deleting menu item works in e.beforeShowContextMenu ), fixed command items (buttons) and command items with popup menus (bookmark "options" command item) - those seem to be fixed - items not re-generated every time the menu shows. Of course, I want to also hide all those popup items that are disabled.
Now, as stated before, in the cmd bar, I can delete a command item but then it is gone for good (until document closed/reopened) - I do not want this - I want to be able to show/hide command items (/commands). Also, as stated in the first post, there appear to be CommandItem methods to Show() or SetStyle() - but nothing seems to work?!
Now, if I really must implement a custom command handler for each an every possible command - I first need to collect all the commands. This must not be done by hand-picking (command ids or string names like "cmd.document.exportBookmarks") what command items appear on the bar of BookmarksView (like expand, collapse, new bookmark) - as with a new version of the SDK you might add more command items to the bar - so this needs to be dynamic.
So, once a first document is loaded, get its BookmarksView, iterate over command panes -> ... -> command items. Collect them all and implement a custom handler for each and every. Do this once - as for a new document the commands on the BookmarksView will be the same and are already custom handled.
And this is only for BookmarsView. I need to do this for all document related panes and their command items / commands.
Is this really what you are telling me? As this might end by custom handling each and every possible command there is.
If this is a must, I find that hard to believe, but ok!
Can you then please provide some code on how to then hide a commandItem when custom handling the command it hosts? What code to put into, I guess, my custom implementation of OnGetItemState
Also, say I'm custom handling "cmd.document.exportBookmarks". How do I go to (get reference to) the document from my IUIX_CmdHandler as for some documents I want to enable/hide this and for some I do not.
And also, when implementing OnGetItemSubMenu (for the "Options..." command item displaying a sub menu) - how do I get the Owner for the OnGetItemState for the items of the popup menu?
And more "how do I ..." probably to come...