searchView - "Clear Folder List" command - custom handle / or react on event  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: 1372
Joined: Thu Sep 05, 2019 12:35 pm

searchView - "Clear Folder List" command - custom handle / or react on event

Post by zarkogajic »

Hi support,

I need to react when the "Clear Folder List" command (menu item in the "Where would you like to search?" combo) in search View is executed.

Is there an even to catch when this is executed or cmdID/name (I do not see it in CmdManager.Cmds) to custom handle?

p.s.
I' ve tried wrapping IPXV_SearchView and then overriding RemoveRecentFolders but the method does not get called...

p.s.2
I can also react on Combo's List's Callback List_OnItemClick - but from the parameters available - no need to know this item is clicked ...

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by Sasha - Tracker Dev Team »

Hello žarko,

There is a way of getting that item - when it's being inserted into the combo box, it is being given a custom parameter of (-1002). That param can be obtained from the UIX_ListItemID.nParam value.

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by zarkogajic »

Hi Alex,

Thanks.

That will be some heavy hard coding (and it works) :)

How sure can I be that this value will not change in the future?

Also, once clicked a dialog will popup asking the user should the action be actually done - now I need to know what the user has decide: yes or no (?) :)

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by Sasha - Tracker Dev Team »

Hello žarko,

That value is a hardcoded define - i doubt that someone will change that.
As for the dialog - the e_ShowModal event will be launched after the click and the dialog with the ID "std:MsgBox" will be called.
Then get the IUIX_Button with the ID "yes" and "no" from that dialog and add a Object Event Target for their objects:

Code: Select all

public partial class ObjectEventTarget :
PDFXEdit.IUIX_ObjImpl,
IDisposable
{
	public ObjectEventTarget(PDFXEdit.IUIX_Obj obj)
	{
		Obj_ = obj;
		if (Obj_ != null)
			Obj_.PushImpl(this);
	}
	~ObjectEventTarget()
	{
		Dispose();
	}
	//Disposing of all of the links we made with objects and parent
	public void Dispose()
	{
		if (Disposed_)
			return;
		Disposed_ = true;
		if (Obj_ != null)
		{
			Obj_.PopImpl(this);
			System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj_);
			Obj_ = null;
		}
	}

	//Object for which we are implementing the custom event listener
	public PDFXEdit.IUIX_Obj Obj_;
	//Used for single dispose control
	private bool Disposed_ = false;

	// IUIX_ObjImpl
	public PDFXEdit.IUIX_Obj Obj
	{
		get { return this.Obj_; }
	}
	//Getting Y coordinate from event param2
	public static short HiWord(uint dword)
	{
		return (short)(dword >> 16);
	}
	//Getting X coordinate from event param2
	public static short LoWord(uint dword)
	{
		return (short)dword;
	}

	//Event listener that listens for all of the needed events
	public void OnEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
	{
		//If the event is not handled then it will be 
		pEvent.Handled = false;
		//
		if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Notify)
		{
			IntPtr outPtr = new IntPtr((long)pEvent.Param1);
			PDFXEdit.UIX_NotifyInfo ni = (PDFXEdit.UIX_NotifyInfo)System.Runtime.InteropServices.Marshal.PtrToStructure(outPtr, typeof(PDFXEdit.UIX_NotifyInfo));
			if (ni.nCode == (int)PDFXEdit.UIX_NotifyCodes.UIX_Notify_Clicked)
			{
				//The button was clicked
			}
		}
		else if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_BeforeDestroy)
		{
			Dispose();
		}
		else if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Last)
		{
			Dispose();
		}
	}

	public void OnPostEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
	{

	}

	public void OnPreEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
	{

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by zarkogajic »

Alex,

Thanks, that does it.

Actually I needed to listen to the result of that dialog and then react if "yes" was clicked (so no need to custom implement IUIX_ObjImpl for "yes" button), that is: look for pEvent.Param1 = UIX_Yes in pEvent.Code = e_EndModal.

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by Sasha - Tracker Dev Team »

Hello žarko,

Well that's good that you needed the easier way - the sample that I gave will help if you need to listen to something dialog related like button presses etc.

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

Re: searchView - "Clear Folder List" command - custom handle / or react on event

Post by zarkogajic »

Hi Support,

Is there an event to catch when "RemoveRecentFolders" is (to be) executed in SearchView?

Previous posts in this topic discuss how to catch the "Yes" or "No" buttons in that dialogs EndModal event:

image.png
image.png (65.84 KiB) Viewed 1523 times

So, I have my custom IUIX_EventMonitor for "std:MsgBox" and I can get into if the Yes or NO buttons are clicked.

However it seems recent folders are already cleared at that e.EndModal/e_PreEndModal moment. I've even tried changing pEvent.Param1 from UIX_Yes to UIX_No - but folders are cleared anyway.

I need to ensure my "special" folder is always in the list (and I know how to add it from code) - so when the folders are cleared in the above way I need an event to catch to inject my folder back to the list.


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

Re: searchView - "Clear Folder List" command - custom handle / or react on event  SOLVED

Post by zarkogajic »

Solved this by posting (and handling) a custom WM_USER message to the PXVControl when clicking on that "Yes" (clear recent folders) button.

p.s.
I guess I could also do my custom IEvent and then Inst.EventServer.FireEvent ... but above works - so let's not complicate :)

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

searchView - "Clear Folder List" command - custom handle / or react on event

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply