Results 1 to 3 of 3

Thread: webbrowser control keypress of Ctrl + N

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    webbrowser control keypress of Ctrl + N

    OK: i have found this code in a post, whilst trying to find right click....

    now im guessin i need reference to the MS HTML Object etc...


    but it still errors.. what else do i need to add to the code? is the code complete or?

    VB Code:
    1. Private Sub webPage_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2. Set doc = webPage.Document
    3. End Sub
    4.  
    5. Private Sub doc_onmousedown()
    6. Dim eventObj As IHTMLEventObj
    7. Set eventObj = doc.parentWindow.event
    8. If eventObj.Button = rightButton Then
    9.     If doc.selection.Type = "Text" Then
    10.    
    11.     End If
    12.     PopupMenu mnuPage
    13. End If
    14. End Sub


    i also found mension in another post about doc_onkeypress

    but they didnt know the sections the functions had,

    now, these posts are like ages old. so, can any of you guys help me with either of these please....

    thanks
    Last edited by wpearsall; Apr 29th, 2003 at 05:48 PM.
    Wayne

  2. #2

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    OK: i found this post in [this thread]

    Originally posted by PunkRockNeil

    With javascript you can determine the keypressed with the "keyCode" property of the event object...For example:

    Code:
    // if the user presses enter call the chkForm function
    if (event.keyCode == 13){
        chkForm();
    }
    now, i know i can call javascript functions from within vb, using the .Document property, but i dont know how i can implement this, into CANCELING the keypress in the browser,

    but load a new form of my own program to handle the new windows..

    can ne one help me with this please?

    Thanks
    Wayne
    Wayne

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    ok then,

    this is what i have:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents Doc As HTMLDocument
    4.  
    5. Private Sub Doc_onmousedown()
    6.     Dim eventObj As IHTMLEventObj
    7.     Set eventObj = Doc.parentWindow.event
    8.     If eventObj.Button = vbRightButton Then
    9.    
    10.         PopupMenu frmMain.mnuTools
    11.        
    12.     End If
    13. End Sub
    14.  
    15. Private Function Doc_onkeypress() As Boolean
    16.  
    17.     Dim eventObj As IHTMLEventObj
    18.     Set eventObj = Doc.parentWindow.event
    19.     If eventObj.keycode = 14 Then
    20.         Doc_onkeypress = False
    21.         call frmMain.LoadNewDoc ()
    22.     Else
    23.         Doc_onkeypress = True
    24.     End If
    25.    
    26. End Function
    27.  
    28.  
    29. Private Sub brwWebBrowser_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, cancel As Boolean)
    30.    
    31.     Set Doc = Nothing
    32.    
    33. End Sub
    34.  
    35. Private Sub brwWebBrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    36. On Error Resume Next
    37.     Set Doc = brwWebBrowser.Document
    38. End Sub

    The right click works FINE!

    keypress doesn't.

    i can cancel presses like a-z 0-9, but i cant cancel control & N

    it wont work like this for some reason?

    can anyone help me with this please?


    i am guessing this is the fact that ctrl & n is a shortcut, therefore the onkeypress dont control it?

    but i cant think of anything else to try as of yet... anyone want to help wid dis plz
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width