Page 1 of 1
use my own dialog boxes
Posted: Mon Sep 24, 2018 12:41 pm
by jusWest
How could I go about using my own dialog boxes instead of the pdfxchange dialogs.
For now I really like to replace the dialog that pops up when you press delete on a bookmark.
Do I need to write a custom command handler?
See attached image.
Re: use my own dialog boxes
Posted: Tue Sep 25, 2018 12:12 pm
by Tracker Supp-Stefan
Hello jusWest,
I've asked a colleague in the dev team for his assistance with this. Please note that it might not be possible at all to replace the default dialogues, but I will know more once I get my colleague's reply!
I will post here as soon as I have any further info.
Regards,
Stefan
Re: use my own dialog boxes
Posted: Tue Sep 25, 2018 8:07 pm
by Vasyl-Tracker Dev Team
Hi jusWest.
Yes, you would be able to replace this (and any other dlg) using the following:
Code: Select all
public partial class MyEventMon : PDFXEdit.IUIX_EventMonitor
{
public void OnEventMonitor(PDFXEdit.IUIX_Obj pTarget, PDFXEdit.IUIX_Event pEvent)
{
if ((pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_BeginModal)
{
PDFXEdit.IUIX_Inst uiInst = pTarget.ThreadCtx.Inst;
if (pTarget.get_ID() == uiInst.Str2ID("std:MsgBox")) // filter to override msgboxes only
{
IntPtr outPtr;
obj.QueryImpl(typeof(PDFXEdit.IUIX_Dialog).GUID, null, out outPtr);
PDFXEdit.IUIX_Dialog pDlg = (PDFXEdit.IUIX_Dialog)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
if (pDlg != null)
{
PDFXEdit.IUIX_Obj labelObj = pDlg.GetItem("msg:text");
string msgText = label.Text;
// make event handled to skip the original msgbox
pEvent.Handled = true; pEvent.Result = 1;
// show my own msgbox
if (ShowMyMsgBox(msgText))
pEvent.Param1 = PDFXEdit.UIX_MsgBoxResult.UIX_Yes;
else
pEvent.Param1 = PDFXEdit.UIX_MsgBoxResult.UIX_No;
}
}
}
}
}
...
// register once, on start app
em = new MyEventMon();
uiInst.CurrentThreadCtx.RegisterEventMonitor(em);
...
// and unregister on app exit
But unfortunately, if we are talking about overriding the editor's msg-boxes - there is no simple way to distinguish one msgbox from others. This could be a real problem for you, because you may not want to override all existing msgboxes in Editor. Also many of them are too complex(containing lots of buttons and other controls). Currently I can suggest that you try and check the msg text, by some keywords, I guess..
HTH.
Re: use my own dialog boxes
Posted: Wed Sep 26, 2018 8:33 am
by jusWest
Thank you, I got it to work by identifying the text pattern in the dialog box
Re: use my own dialog boxes
Posted: Wed Sep 26, 2018 9:23 am
by Tracker Supp-Stefan