Change Title/Hint for CmdItem based on active document  SOLVED

PDF-XChange Editor SDK for Developers

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

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
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Change Title/Hint for CmdItem based on active document

Post by zarkogajic »

Hi Support,

What would be the way to have a command item (for a custom command) display different Title/Hint related to the currently active document in MainFrame?

I can handle e.document.activated and get the CmdItem and get the Doc - I'm unsure how to change it's Title/Hint.

Note: I do not want to change the corresponding IUIX_Cmd's Title - I only need the CmdItem to display a different Title/Hint - document related.

p.s.
I kind of know this involves IUIX_CmdHandler2 and OnCustomizeItemAppearance and AddNewAppearance ... but I'm slightly lost to when what needs to be called.



-žarko
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Change Title/Hint for CmdItem based on active document

Post by zarkogajic »

Hi Support,

I have it working - but not quite sure I'm using that in the intended way.

It seems that the first time OnCustomizeItemAppearance is called for a specific IUIX_CmdItem If I return E_NOTIMPL it will never be called again for that Cmditem.

if I return S_OK, it will be called everytime for the item when it needs be updated.

Then if I call nNewApp = pItem.Cmd.AddNewAppearance everytime and use pItem.Cmd.SetTitle(nNewApp...) I have the result I wanted.

However, I do not see that being correct - as for the Item where I do not want to change the Title - AddNewAppearance will always add new appearance ... from the UI point ok - but is this how it was meant to be?

Should I be storing nNewApp somehow and simply reuse (if there's no change needed) without again using pItem.Cmd.SetTitle(nNewApp...)?


-žarko
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Change Title/Hint for CmdItem based on active document

Post by Vasyl-Tracker Dev Team »

If you need to have cmdItems with individual text 'per document' you may use two ways:

1. In case, when such cmd is located just on any documen's toolbar (not on mainframe's Ribbon, or other mainframe's toolbar) - for each document you may use IUIX_CmdManager.CreateNewCmd/CreateNewCmd2 to create new cmd-object. You may use the same ID for all such cmd-object but also you may specify different Title for them. Then add that cmd to certain document's toolbar (for example to cmdbar.docOptions).

2. You may use one global cmd-object, created via IUIX_CmdManager.Cmds.AddNew, and this cmd can 'live' on mainframe's toolbars too. In this case, to provide title/icon per-document - you need to use the cmd's Appearances.
The correct way to use it:
each time, when you open a new document you need to add a new Appearance to that cmd OR reuse the idle one which is left after another doc was closed. It means you need to have an array of pairs like {docID, appID}, and when document is closed you may put zero to docID to signal that the corresponding Appearance is free for future usage. Then having this array you will be able to return the proper appID, according to the document, in the OnCustomizeItemAppearance.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Change Title/Hint for CmdItem based on active document  SOLVED

Post by zarkogajic »

Vasyl,

Great, thanks.

I'm using (2) - MainView bars - same Commands for all documents, but a few of those are document-related (their Title/Tip).

-žarko
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8439
Joined: Wed Jan 03, 2018 6:52 pm

Change Title/Hint for CmdItem based on active document

Post by TrackerSupp-Daniel »

:)
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Post Reply