History - how to remove (missing) items  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

History - how to remove (missing) items

Post by zarkogajic »

Hi support,

I'd like to remove the item from the history list - if the file in the history is missing, that is if "the system cannot find the file specified" would appear as the error in the preview.

Is there an event to catch (and I've tried e.history.itemAdded but no luck) when the open history is populated from the history settings file to catch and do the above ?


-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team »

Hello žarko,

Sadly there is no method or event to catch to tweak the item insertion. There is an End-User solution to this one, though it requires the dialog to popup. History View/Options/Clear.../Remove/All Broken

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Hi Alex,

Let's say I do not mind popup to get visible briefly ... can this be done from code:

image.png

?

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

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team »

Hello žarko,

There is an easier way - execute an cmd.historyList.clear command and that dialog will show. Before that, you can set the Operations.ClearHistory.Filter setting to 1 (Broken) and the checkbox will select the needed item. Then you should catch the e_ShowModal event in the OnEventMonitor method:

Code: Select all

public void OnEventMonitor(PDFXEdit.IUIX_Obj pTarget, PDFXEdit.IUIX_Event pEvent)
			{
				if (pEvent.Code == (uint)PDFXEdit.UIX_EventCodes.e_ShowModal)
				{
					IntPtr outPtr;
					pTarget.QueryImpl(typeof(PDFXEdit.IUIX_Dialog).GUID, null, out outPtr);
					PDFXEdit.IUIX_Dialog dlg = (PDFXEdit.IUIX_Dialog)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
					if (dlg == null)
						return;
					//Here check the dialog ID - should be DlgClearHistory
					
					//
					PDFXEdit.IUIX_Obj btnObj = dlg.GetItem("btn.ok");
					btnObj.QueryImpl(typeof(PDFXEdit.IUIX_Button).GUID, null, out outPtr);
					PDFXEdit.IUIX_Button btn = (PDFXEdit.IUIX_Button)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
					objectTarget = new ObjectEventTarget(btn.Obj);
					btn.AutoClick(0);
				}
			}

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Hi Alex,
execute an cmd.historyList.clear command and that dialog will show.
I've tried this (so only execute that command), but nothing happens :( Should I do something before?

p.s.
I can execute "cmd.manageHistory", but from there I would then need to auto click the "Clear..." button and that will dispaly the "Clear History" dialog...

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team »

Hello zarko,

You will have to specify the owner of the command - and that is the HistoryView:

Code: Select all

int nID = pdfCtl.Inst.Str2ID("historyView");
PDFXEdit.IPXV_View view = pdfCtl.Frame.View.Panes.Active[nID];
pdfCtl.Inst.ExecUICmd("cmd.historyList.clear", view.Obj);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Hi Alex,

Thanks. This helped and the dialog is displayed.

I have the btn but nothing happens after AutoClick(0) - the dialog does not get closed nor are the broken items removed from the history.

Also, what is this for:

"objectTarget = new ObjectEventTarget(btn.Obj);"

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

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team »

Hello žarko,

Code: Select all

objectTarget = new ObjectEventTarget(btn.Obj);
This is the leftovers of the code piece that can help you listen to the clicked event for example (made a sample for someone some time ago).

As for the autoclick - it seems that you will need to specify at least 1 second as a timeout (1 as a parameter - then it will work). Though the dialog will hang for a second.

I have a solution to this one that I have made earlier for my own purposes - I've emulated a physical user click on that button. Here's the code that should help:

Code: Select all

					PDFXEdit.UIX_NotifyInfo ni = new PDFXEdit.UIX_NotifyInfo();
						ni.nCode = (int)PDFXEdit.UIX_NotifyCodes.UIX_Notify_Clicked;
						ni.pFrom = dlg.GetItem("btn.ok");
						IntPtr ptr;
						ni.pFrom.QueryImpl(typeof(PDFXEdit.IUIX_ObjImpl).GUID, null, out ptr);
						PDFXEdit.IUIX_ObjImpl uiObjImpl = (PDFXEdit.IUIX_ObjImpl)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(ptr);
						ni.pFromImpl = uiObjImpl;
						ni.nFromID = ni.pFrom.ID;
						ni.pData = 0;

						evt.nCode = (int)PDFXEdit.UIX_EventCodes.e_Notify;
						IntPtr resPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ni));
						System.Runtime.InteropServices.Marshal.StructureToPtr(ni, resPtr, false);
						evt.nParam1 = (uint)resPtr;
						SV.Obj.SendRawEvent(ref evt);

						Marshal.FreeHGlobal(resPtr);
						resPtr = IntPtr.Zero;
						System.Runtime.InteropServices.Marshal.Release(ptr);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Hi Alex,

Thanks, will try the "emulated click" ..

Btw, what is "SV" in "SV.Obj.SendRawEvent(ref evt);" ?

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

Re: History - how to remove (missing) items

Post by Sasha - Tracker Dev Team »

Hello žarko,

Call this for your dialog's object.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Alex,

After a successful mimic-click, now we have this dialog :)

image.png
image.png (95.69 KiB) Viewed 3039 times

Can I somehow pre-set "yes, and don't ask again" ?

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

Re: History - how to remove (missing) items  SOLVED

Post by Sasha - Tracker Dev Team »

Hello žarko,

You can set the Prompts.AskForDeleteHistory setting to false - that dialog window won't be shown afterwards.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: History - how to remove (missing) items

Post by zarkogajic »

Hi Alex,

Thanks, that does it :)

User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: History - how to remove (missing) items

Post by Will - Tracker Supp »

:D
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Post Reply