How to hide a disabled CommandItem?

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Posts: 152
Joined: Thu Sep 05, 2019 12:35 pm

How to hide a disabled CommandItem?

Post by zarkogajic » Wed Oct 09, 2019 4:07 pm

Hi support,

There are multiple topics asking how to hide some command/command items on various panes.

In most cases the suggestion is to use IUIX_CmdItem.Delete, like in here: viewtopic.php?f=66&t=27821

This does the trick of "hiding" a command item, but once deleted, no way to have it back (as it no longer appears in its IUIX_CmdItemBox.Items collection).

[Q1] So, is there a way to really hide a command item (and not delete)?

I've tried using:

Code: Select all

cmdItem : IUIX_CmdItem;


cmdItem.SetStyle(UIX_CmdItemStyle_Hidden, UIX_CmdItemStyle_Hidden)

InstUI.CmdManager.UpdateCmdItems(UIX_CmdItemUpdate_Style, cmdItem.Cmd.ID);

but nothing works (i.e. the command item is still visible).

Hiding the icon, using UIX_CmdItemStyle_HideIcon does work though - but I simply cannot hide the entire item.

[Q2] Also, how come that cmdItem.IsDisabled can be true but the state is not UIX_CmdItemState_Disabled.

Example (BookmarksView command bar), having "New Bookmark" (appears as) not enabled (as document opened in "read-only" mode):

Code: Select all, cmdItem.IsDisabled : True, UIX_CmdItemState_Disabled: False
The state returned by

Code: Select all

//maybe this is not the correct call?
cmdItem.Cmd.Handler.OnGetItemState(cmdItem.Cmd, cmdItem, pxv_Control.Doc.ActiveView.BookmarksView.Obj, cmdItemState);

//cmdItemState is $FF, not UIX_CmdItemState_Disabled.
However, for "Delete" command item (also appears as not enabled):

Code: Select all

ID:cmd.delete, cmdItem.IsDisabled : False, UIX_CmdItemState_Disabled: True


User avatar
Sasha - Tracker Dev Team
Posts: 4316
Joined: Fri Nov 21, 2014 8:27 am

Re: How to hide a disabled CommandItem?

Post by Sasha - Tracker Dev Team » Fri Oct 11, 2019 7:39 am

Hello žarko,

You can set the hidden state by using a custom command handler.
The command can be disabled by setting the Offline property, not just state.

Join us at Google+:
Subscribe at:

Posts: 152
Joined: Thu Sep 05, 2019 12:35 pm

Re: How to hide a disabled CommandItem?

Post by zarkogajic » Fri Oct 11, 2019 7:28 pm

Hi Alex,

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.

[Q] 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...

Post Reply