Use shortcuts if PDF-XChange Viewer control is embedded

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm
Location: Salzburg - AUSTRIA
Contact:

Use shortcuts if PDF-XChange Viewer control is embedded

Post by KarlTH »

Hello Support-Team,

I have embedded the PDF-XChange Viewer control on a form in a VB .NET application and have the problem that the built-in keyboard shortcuts does not work in the PDF-XChange Viewer control. :shock:
The only work if I click with the mouse on the command in the menu bar.

The PDF-XChange Viewer control receives the keyboard shortcuts e.g. CTRL + O but does not call the appropriate command e.g. Open(57601).
How can I connect all built-in shortcuts ot the PDF-XChange Viewer control with the appropriate commands?

Here is my code, where I am catching the shortcuts:

Code: Select all

Private Sub AxPDFXViewCtrl_OnEvent(sender As Object, e As AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent) Handles AxPDFXViewCtrl.OnEvent
        Dim oDataIn As Object
        Dim oDataOut As Object

        If e.type = PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnNamedNotify And e.name = "Global::CheckKey" Or _
            e.type = PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnNamedNotify And e.name = "Global::CheckSysKey" Then

            AxPDFXViewCtrl.DoVerb("Notifications.Keyboard", ".SP", oDataIn, oDataOut, 0)
            Dim mKeyBoard As PDFXCviewAxLib.IPDFXCsmartp
            mKeyBoard = CType(oDataOut, PDFXCviewAxLib.IPDFXCsmartp)

            mKeyBoard.GetProperty("Msg", oDataOut, 0)
            Debug.Print(oDataOut.ToString)

            mKeyBoard.GetProperty("Code", oDataOut, 0)
            Debug.Print(oDataOut.ToString)

            mKeyBoard.GetProperty("RepCnt", oDataOut, 0)
            Debug.Print(oDataOut.ToString)

            mKeyBoard.GetProperty("Flags", oDataOut, 0)
            Debug.Print(oDataOut.ToString)
        End If

Thanks,

Karl
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by Nico - Tracker Supp »

Hi Karl,

Thank you for your post.
To detect keyboard notifications you need to enable them first:
// pseudo-code
SetProperty("Notifications.Keyboard.Filter", "All", 0);

Then, on the event handler you need to detect the target keyboard combination (in this case, CTRL + O)
// pseudo-code

function OnEvent(Type, Name, DataIn, DataOut)
{
if (Type == PXCVA_OnNamedNotify && Name == "Notifications.Keyboard")
{
GetProperty("Notifications.Keyboard.Code", vCode, 0);
GetProperty("Notifications.Keyboard.Msg", vMsg, 0);
if ( vMsg == WM_KEYDOWN && vCode == 79 && GetAsyncKeyState(VK_CONTROL))
{
// Set flag to call OpenDocument
OpenDocument = TRUE;
}
}
}

After you exit the event handler, you can check the flag and call OpenDocument
// pseudo-code
OpenDocument(NULL, NULL, NULL, 0);

Thanks.
Sincerely;
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm
Location: Salzburg - AUSTRIA
Contact:

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by KarlTH »

Hello Nico,

thank for your fast reply and the code but I wanted to know if I can make all the built-in keyboard shortcuts of the PDF-XChange Viewer control work. I do not want to call each menu item, in the event! I am sorry my code example was a bit confusing. What I mean is something like the property KeyPreview(Me.KeyPreview = True) on a windows form which I enable and then all the keyboard shortcuts call the appropriate menu items.

Is there any call to redirect all keyboard shortcuts to the appropriate menu item?
Or have I to catch each event separately?


Best regards,

Karl
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by Nico - Tracker Supp »

Hi Karl,

Thank you for your post.
I guess you are asking how to change the keyboard shortcuts? You can specify this by calling SetProperty() method.
// pseudo-code
SetProperty("Commands[\"Open\"].Shortcut.Modifiers", 8 | 4); // CTRL + SHIFT
SetProperty("Commands[\"Open\"].Shortcut.Key", 'X'); // 'X' key
You can enable them by setting property "General.AllowAllAccelerators" to TRUE.
Please take a look at our "Full Demo" example in the Viewer SDK.
Thanks.
Sincerely,
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm
Location: Salzburg - AUSTRIA
Contact:

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by KarlTH »

Hello Nico,

no I do not want to assign own keyboard shortcuts, I only want to use the existing built-in keyboard shortcuts.
In the end user product the keyboard shortcuts work(e.g. CTRL + O shows open file dialog) but in the PDF-XChange Viewer control in my VB .NET application they do not work(e.g. CTRL + O does nothing).
Can I enable the built-in keyboard shortcuts of the PDF-XChange Viewer control anywhere?


Thank you for patience,

Karl
KarlTH
User
Posts: 57
Joined: Mon Aug 01, 2005 2:33 pm
Location: Salzburg - AUSTRIA
Contact:

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by KarlTH »

Hello Nico,

I am sorry I should have read your post more exactly! :oops:
When I set the property AllowAccelerators to True then all the built-in keyboard shortcuts work like I want. :D

Code: Select all

AxPDFXViewCtrl.AllowAccelerators = True

Thank you very much!

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

Re: Use shortcuts if PDF-XChange Viewer control is embedded

Post by Tracker Supp-Stefan »

Glad all is sorted out now Karl! :)

Cheers,
Stefan
Post Reply