Duplication a Form
- I have a web browser. and I would like button that duplicated the form. (i.e. if you press CTRL + N in internet explorer)
Answers
Does your form have a property for the current URL? You would simply create a new instance of your form and set the URL property of that instance to the link that was clicked.
Dim newForm as Form1 = New Form1
newForm.URL = <the URL for the link that was clicked>
newForm.Show
Or, you could create a constructor that took the link as an argument, so creating the new instance and settng the URL for that instance would become:
Dim newForm as Form1 = New Form1(<the URL for the link that was clicked>)
newForm.Show- Marked As Answer byidspence Wednesday, November 11, 2009 9:04 PM
All Replies
- If you want that, run/launch another instance of your program and pass the current webpage url to your webbrowser.
kaymaf
If that what you want, take it. If not, ignored it and no complain- Marked As Answer byJeff ShanMSFT, ModeratorWednesday, November 11, 2009 1:32 AM
- Unmarked As Answer byidspence Wednesday, November 11, 2009 9:22 AM
- what?
- You can have as many instances of your form as you require.
Dim newForm as Form1 = New Form1
newForm.Show
Note that if you repeat that you will not be able to reference the new forms from the first form that you start. But if each form is independent and includes functions for closing etc, then that doesn't matter. If you want to keep track of the forms you create and be able to manage the from the first form (eg, tabs as in IE), then you need to add some extra code to do that. - okay great :D. how would i be able to use that code when the user click a link in the webbrowser that opens in a new window?
Does your form have a property for the current URL? You would simply create a new instance of your form and set the URL property of that instance to the link that was clicked.
Dim newForm as Form1 = New Form1
newForm.URL = <the URL for the link that was clicked>
newForm.Show
Or, you could create a constructor that took the link as an argument, so creating the new instance and settng the URL for that instance would become:
Dim newForm as Form1 = New Form1(<the URL for the link that was clicked>)
newForm.Show- Marked As Answer byidspence Wednesday, November 11, 2009 9:04 PM
- Okay / thats answers my first question but i dont think you fully understood what I ment.When a HTML link has the
<a href="http://www.microsoft.com/" target="_blank">New Window Link</a>
target="_blank"
in the .html file the link opens up in a new window. But in my web browser that link would open up in internet explorer. How do i make it so it opens up in a new windows under my application? - Your question was "...and I would like button that duplicated the form" In this case, the button would execute the code to duplicate the form, using the address you will provide (eg, from a tag on the current page, or a default). In other words, the user decides that they want a new form to open, and indicates that by clicking the button.
The question now appears to be "How do I intercept a user clicking a link within the browser when the link target is "_blank" and execute my own code, eg open up a new form with a default site?" This is a very different issue, as it means that you need to add code to the browser events to intercept attempts to move to a new site.
The Navigating event occurs before the browser navigates to the selected site. The URL argument of the event args gives the url that the browser is about to navigate to. So for the above case, you can add code to the Navigating event, check the URL, and if it is one that open up IE, stop the navigation and open your new page (with a default URL) instead.
- when i said " but i dont think you fully understood what I ment. " i was trying to save a post. but i guess ill make a new post and ask the above question.
- The Navigating event, which occurs in response to the user's attempt to move to a new site, includes a property in the event args that tells you the site they are moving to. If you intercept that event and look at the URL, you can detect if it is _blank, cancel the navigation, and open your additional form with a default addres.


