Results 1 to 5 of 5

Thread: Ctrl+N To Open New Browser Window

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Question Ctrl+N To Open New Browser Window

    The File menu in a web browser project has a sub-menu New. New also has a sub-menu Window named mnuNewWindow. Clicking the Window menu, as usual, opens a new instance of the browser. Ctrl+N has been assigned the shortcut key for Window at design time.

    Now what I find is if I press Ctrl+N on the keyboard, not only a new browser window opens but at the same time Windows Explorer's C:\ drive opens up as well (maybe because that is where WinXP is installed).

    If I change the shortcut key of Window to, say, Ctrl+Q & press Ctrl+Q on the keyboard, then only a new browser window opens up. I also tried other shortcut combinations & all of them open only a new browser window (& not C:\ along with the new browser window). The problem is only with Ctrl+N. This is how I tried it:

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If (Shift = 2 And KeyCode = 78) Then
            Call mnuNewWindow_Click
        End If
    End Sub
    
    Private Sub mnuNewWindow_Click()
        Dim frmNewWindow As frmWebBrowser
        
        Set frmNewWindow = New frmWebBrowser
        frmNewWindow.Show
        frmNewWindow.wWeb.Navigate2 "http://www.SomeURL.com"
    End Sub
    What's causing this problem? How do I ensure that pressing Ctrl+N only opens a new browser window?

    Note that I have set the KeyPreview property of the Form which houses the WebBrowser control to True.

    Of course, I can assign any other shortcut to Window but since Ctrl+N has been the universally accepted key combination to open a new instance of an app, I did like to adhere to Ctrl+N to open a new browser window.


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  2. #2
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: Ctrl+N To Open New Browser Window

    Question, and I don't know if this relates to your problem: Why not just assign Ctrl+N as the shortcut key using the menu editor? This will eliminate the need for the code in the KeyDown event, and should give more clarity on the matter.

    My suspicions are that, when you hit CTRL+N, the main form sees the event, opens the frmnewWindow, and then as the webbrowser control is selected, it fires CTRL+N again... (Like a delay on the keyboard almost...)

    If you change it to use CTRL+O, does it show an Open dialog?

  3. #3

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Ctrl+N To Open New Browser Window

    Why not just assign Ctrl+N as the shortcut key using the menu editor?
    That's what I first did but since it didn't work, I added the code in the Form's KeyDown event.

    Any other suggestions?


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  4. #4
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: Ctrl+N To Open New Browser Window

    Temporarily change the shortcut to CTRL+O and check if an open dialog pops up. If this happens, we at least know what the problem is.

    Solving it will be a bit harder, though.

  5. #5

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Ctrl+N To Open New Browser Window

    No Ctrl+O does not invoke the open dialog. In fact, nothing happens though I have set it as a shortcut key in the Menu Editor (which should open a new Form similar to the dialog that opens up when you press Ctrl+O in IE.


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

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