Disable context menu on tab

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
edvschu
User
Posts: 127
Joined: Fri Jun 25, 2010 6:54 am

Disable context menu on tab

Post by edvschu »

Hello,

how can i disable context menu right click on tab?

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

Re: Disable context menu on tab

Post by Tracker Supp-Stefan »

Hello edvschu,

I believe this topics shows how to handle the context menu events:
https://www.pdf-xchange.com/forum3 ... it=Context

Cheers,
Stefan
edvschu
User
Posts: 127
Joined: Fri Jun 25, 2010 6:54 am

Re: Disable context menu on tab

Post by edvschu »

Hello Stefan,

the post I've already discovered and tried it. But event beforeShowContextMenu is not trigger by right click on tab.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable context menu on tab

Post by Sasha - Tracker Dev Team »

Hello edvschu,

You will need a CustomEventTarget for this one. Here's a sample that I have on this one:
https://gist.github.com/Polaringu/f3de7 ... 65695e364c
It should be initialized for DocViewArea object:

Code: Select all

myEventTarget = new CustomEventTarget(pdfCtl.Inst.MainFrm[0].View.DocViewsArea.Obj, this);
And you will have to catch a notify that a context menu will appear:

Code: Select all

else if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Notify)
{
	IntPtr outPtr = new IntPtr(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_Layout_ShowContextMenu)
	{
		pEvent.Handled = true;
	}
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
edvschu
User
Posts: 127
Joined: Fri Jun 25, 2010 6:54 am

Re: Disable context menu on tab

Post by edvschu »

Thanks Alex for the perfect help.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Disable context menu on tab

Post by Tracker Supp-Stefan »

:)
dconner
User
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: Disable context menu on tab

Post by dconner »

Hi All!

I seem to be having a problem with this example.

I create a new instance of CustomEventTarget:

custEventTarget = new CustomEventTarget(pdfx.Inst.MainFrm[0].View.DocViewsArea.Obj, this);

Then when this event is triggered:

public void OnEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
{
if (pEvent.Code == (int)PDFXEdit.UIX_EventCodes.e_Notify)
{
IntPtr outPtr = new IntPtr(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_Layout_ShowContextMenu)
Parent.InvokeNotifyPopupShownEvent("", "", (uint)ni.nCode);
}
}

Some codes seems to be coming through. However, "UIX_Notify_Layout_ShowContextMenu" is definitely not one of them. Any ideas?

I'm trying to prevent the default context menus from showing so that I may show my own. Thanks for your time!
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable context menu on tab

Post by Sasha - Tracker Dev Team »

Hello dconner,

Please include a small sample project that illustrates this issue and the reproduction steps so we can debug it here.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
dconner
User
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: Disable context menu

Post by dconner »

I managed to accomplish the task using the "OnEventMonitor" without creating a "CustomEventTarget".

Code: Select all

        public void OnEventMonitor(IUIX_Obj pTarget, IUIX_Event pEvent)
        {
            if (pEvent.Code == (uint)PDFXEdit.UIX_EventCodes.e_Notify)
            {
                IntPtr outPtr = new IntPtr(pEvent.Param1);
                if (!pTarget.IsInvalid && pTarget.Windowed)
                {
                    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_PopupShowed)
                    {
                        var handle = ni.pFrom.WndHandle;
                        string txt = ni.pFrom.Text;
                        string cname = "";
                        uint parentHandle = pTarget.WndHandle;
                        int parentId = pTarget.get_ID();

                        if (ni.pFrom.ThemeClass != null) cname = ni.pFrom.ThemeClass.ID;
                        var res = pdfctrl.InvokeNotifyPopupShownEvent(txt, cname, handle, parentHandle, parentId);
                        if (res)
                        {
                            ni.pFrom.VisibleCondition = false;
                            tagRECT tg = new tagRECT();
                            tg.top = 0;
                            tg.left = 0;
                            tg.right = -1;
                            tg.bottom = -1;
                            ni.pFrom.set_Rect(ref tg);
                        }
                    }
                    pEvent.Handled = true;
                    return;
                }
            }
        }
Now I am using the ParentId to identify the context menu:

Code: Select all

    public class PopupHandler
    {
        public static bool ProcessBeforePopupShownEvent(uint PopupWindowHandle, uint PopupWindowParentHandle, int PopupWindowParentId)
        {
            if (PopupWindowParentId != 0)
            {
                if (PopupWindowHandle != 0)
                {
                    //main form context menu
                    if (PopupWindowParentId == 24)
                    {
                        return true;
                    }
                    //thumbnails context menu
                    if (PopupWindowParentId == 25)
                    {
                        return true;
                    }
                    //bookmarks context menu
                    if (PopupWindowParentId == 26)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
    }
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Disable context menu on tab

Post by Sasha - Tracker Dev Team »

Hello dconner,

If that is working for you then great :)

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply