KeyCodes with Notifications.Keyboard.Code

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

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

asadatec
User
Posts: 5
Joined: Tue Nov 10, 2009 10:20 am

KeyCodes with Notifications.Keyboard.Code

Post by asadatec »

Hello together,
I want my software to switch to fullscreen when the user presses F11 (also within the PDF control). So my program is listening to key events. I wonder why one keypress raises the event twice sometimes.

Code: Select all

        _PDFViewer.SetProperty("Notifications.Print.Filter", "All", 0)
        _PDFViewer.SetProperty("Notifications.TextEditor.Filter", "All", 0)
        _PDFViewer.SetProperty("Notifications.Keyboard.Filter", "All", 0)

Code: Select all

    Private Sub _PDFViewer_OnEvent(ByVal sender As Object, ByVal e As AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent) Handles _PDFViewer.OnEvent
            If e.name.ToLower.Contains("notifications.keyboard") Then
                Dim Code As Integer
                _PDFViewer.GetProperty("Notifications.Keyboard.Code", Code, 0)
#If DEBUG Then
                Debug.Print("KeyPress: " & Code.ToString)
#End If
Example: Pressing A returns
KeyPress: 97
KeyPress: 65

Pressing F11 gives me
KeyPress: 122 <- This is the code I am waiting for

BUT pressing Z (German keyboard layout) gives me
KeyPress: 90
KeyPress: 122

So when you type Z within a PDF my program switches to fullscreen. What can I do?
Thank You,
Sebastian
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: KeyCodes with Notifications.Keyboard.Code

Post by Vasyl - PDF-XChange »

Hi, asadatec.

Your sample is 'too wide keyboard-catcher'. Try other code - it catches the 'WM_KEYDOWN' events only:

Code: Select all

Private Sub _PDFViewer_OnEvent(ByVal sender As Object, ByVal e As AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent) Handles _PDFViewer.OnEvent
    If e.name.ToLower.Contains("notifications.keyboard") Then
        Dim Msg As Integer
        _PDFViewer.GetProperty("Notifications.Keyboard.Msg", Msg, 0)
        If Msg = 256 Then ; WM_KEYDOWN is pressed              
            Dim Code As Integer
            _PDFViewer.GetProperty("Notifications.Keyboard.Code", Code, 0)
            If Code = 122 Then ; F11
                _PDFViewer.SetProperty("Notifications.Keyboard.Skip", 1, 0) ; to skip processing the F11 in our viewer
                ;; turn on/off the FullScreen mode
 
            End If
        End If
    End If
HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
asadatec
User
Posts: 5
Joined: Tue Nov 10, 2009 10:20 am

Re: KeyCodes with Notifications.Keyboard.Code

Post by asadatec »

Thanks, that works better
Thank You,
Sebastian
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: KeyCodes with Notifications.Keyboard.Code

Post by Stefan - PDF-XChange »

:)