use my own dialog boxes

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
jusWest
User
Posts: 69
Joined: Fri Aug 24, 2018 8:26 am

use my own dialog boxes

Post by jusWest » Mon Sep 24, 2018 12:41 pm

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.
Attachments
dialog1.PNG
dialog1.PNG (38.36 KiB) Viewed 546 times

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13557
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: use my own dialog boxes

Post by Tracker Supp-Stefan » Tue Sep 25, 2018 12:12 pm

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

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

Re: use my own dialog boxes

Post by Vasyl-Tracker Dev Team » Tue Sep 25, 2018 8:07 pm

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.
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.

jusWest
User
Posts: 69
Joined: Fri Aug 24, 2018 8:26 am

Re: use my own dialog boxes

Post by jusWest » Wed Sep 26, 2018 8:33 am

Thank you, I got it to work by identifying the text pattern in the dialog box :)

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13557
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: use my own dialog boxes

Post by Tracker Supp-Stefan » Wed Sep 26, 2018 9:23 am

:D

Post Reply