Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

SSTAB1 Help - a little complex

Greg85374Greg85374 Member Posts: 19
OK..here goes..Ive a Brwser form and a MDiForm(child form) I gave my browser for a similar functin to Netscape. I want the user to open another browser in a new tab. sO I did it the easieast way.. I put a browser on each of my 5 tabs. Then I put code in to make the next tab visible everytime the user clicks new tab. No problem.

But now how do I add the code for newtab to the browsers right click event?

After I accomplish that...Ive the following Dilemna...If they have 5 tabs open(the max I allow for that window) And the user select "new window" the Static counter I used to make the next tab visible doesnt reset on the new window.In otherword if the 1st windows open and all five tabs are open..the new window appears and no tabs are visible but they cant open another 5 tabs.

Comments

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : But now how do I add the code for newtab to the browsers right click event?
    :

    Assuming you want to add a menu item to Explorer's existing menu, try searching the net for:

    +"Internet Explorer" +"context menu"

    Or simply install anything that adds such an item and look in the registry for the text of the menuitem. Example: Google toolbar installs a menuitem (among others) named "Translate into English". A look in the registry (the text is a key name) shows that the default value simply points to a file or resource that IE recognizes. If you look in the html file (some use standalone files, Google doesn't), you find that it's often a simple Javascript function that is executed as though it's part of the page.

    The downside is that this menuitem will show up at the bottom (New Tab should probably show up at the top near New Window) and that it will show up in all explorer windows.

    Assuming you want to create your own menu, good luck! I once successfully subclassed the appropriate window and trapped the right-click event but it turned out to almost never work properly.

    : After I accomplish that...Ive the following Dilemna...If they have 5 tabs open(the max I allow for that window) And the user select "new window" the Static counter I used to make the next tab visible doesnt reset on the new window.In otherword if the 1st windows open and all five tabs are open..the new window appears and no tabs are visible but they cant open another 5 tabs.
    :

    Sounds like you're using a global variable in a bas module. Move the variable to the top of the form and it should be fine.
  • Greg85374Greg85374 Member Posts: 19
    no...2b more specific..I already know the registry keys ive to write to..its listed on msdn...at program startup i want to add my option to the registry..and then remove it in the form unload event...to prevent errors in using ie without my program.I know its fairly easy to do this but i personally always(for safety) used INI files instead and cant do that in this case.I just need a method to safely add and remove items from the registry

    Implementation Steps
    The following steps are required to add an entry into the standard context menus in Internet Explorer.

    Create a new key, using the text you want displayed in the context menu as the name, under:
    HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt

    The result should look like:

    HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt should be replaced with the text that you want displayed in the context menu. The name can include an ampersand (&) character, which will cause the character that follows to be underlined and used as a shortcut key.

    Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
    Optional. Create a binary value, Contexts, under:
    HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt

    but how do i do it?



  • infidelinfidel Member Posts: 2,900
    : no...2b more specific..I already know the registry keys ive to write to..its listed on msdn...at program startup i want to add my option to the registry..and then remove it in the form unload event...to prevent errors in using ie without my program.I know its fairly easy to do this but i personally always(for safety) used INI files instead and cant do that in this case.I just need a method to safely add and remove items from the registry
    :
    : Implementation Steps
    : The following steps are required to add an entry into the standard context menus in Internet Explorer.
    :
    : Create a new key, using the text you want displayed in the context menu as the name, under:
    : HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt
    :
    : The result should look like:
    :
    : HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt
    : should be replaced with the text that you want displayed in the context menu. The name can include an ampersand (&) character, which will cause the character that follows to be underlined and used as a shortcut key.
    :
    : Set the default value of the key to the URL of the page that contains the script you want the context menu entry to execute. This script can obtain the parent window object, the screen where the context menu item was executed, from the menuArguments property of the external object.
    : Optional. Create a binary value, Contexts, under:
    : HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerMenuExt

    Even if you add code to remove those registry entries, abnormal termination of your program will prevent that code from running, so it's not a bullet-proof solution.

    If you're using the webbrowser control on a VB form, you can make your own context menu. Add a reference to the Microsoft HTML Objects library and put this at the top of your form module:

    Private WithEvents htmldoc As HTMLDocument

    Now, just set that variable when the browser is finished navigating to a page:

    [code]
    Private Sub browser_DocumentComplete(ByVal pDisp As Object, URL As Variant)

    Set htmldoc = Me.browser.Document

    End Sub
    [/code]

    Now just catch the oncontextmenu event of the htmldoc object:

    [code]
    Private Function htmldoc_oncontextmenu() As Boolean

    Me.PopupMenu mnuPopup

    End Function
    [/code]

    And you can popup any menu you have defined on your form.

    You can get a handle of the object that was right-clicked like this:

    [code]
    Private Sub mnuFoo_Click()

    htmldoc.activeElement.innerText = "FOO"

    End Sub
    [/code]


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

Sign In or Register to comment.