[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open browser in form

Posted on 2005-05-13
13
Medium Priority
?
716 Views
Last Modified: 2010-05-18
I have a form with a browser control whose LocationURL is a Login page at my web site. Once a user logs in, MS Internet Explorer pops open with the web site. What I want to do, instead, is have that web site open up in another browser control on another form. (I hope I'm making sense here) Thanks in advance!
0
Comment
Question by:John Account
  • 6
  • 3
  • 2
  • +1
13 Comments
 
LVL 12

Expert Comment

by:Preece
ID: 13997944
This may work:

Browse and login in Form1 first, then click button to load Form2:

Private Sub Command6_Click()
    Form2.Show
End Sub

Private Sub Form_Load()
    Form2.WebBrowser1.Navigate2 Form1.WebBrowser1.LocationURL
End Sub
0
 

Author Comment

by:John Account
ID: 13997987
uhmmmm...I don't think I was very clear, Preece, sorry. You see, the Login browser in Form1 opens internet exporer to the web site. (The web site DOES NOT open in the browser control in Form1; moreover, since it's a php page, the LocationURL changes once logged in).
0
 
LVL 12

Expert Comment

by:Preece
ID: 13998054
Are you saying that a new instance of IE is opened outside of the form?  If so, then you may have some code something like this that spawns a new instance of IE:

Private Sub cmdSpawnBrowser_Click()
   
    If IEObj Is Nothing Then Set IEObj = New SHDocVw.InternetExplorer
   
    IEObj.Navigate txtURL
    IEObj.Visible = True   'optional if you want to show IE

End Sub


0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:John Account
ID: 13998397
I wish we could draw on these pages, LOL, but imagine this: A very small little area of Form1 is WebBrowser1 whose php page displays 2 fields to Login--one for username, one for password. Moreover, that page contains the following script to open the link:
<script language="JavaScript">
      blah, blah, blah, etc..

window.open('MyPage.php?user='+user+'&pwd='+pwd,'','height=650,width=200,left=500,top=10, toolbars=0,menubar=0,scrollbars=0,status=0;');window.focus();      
      }


0
 

Author Comment

by:John Account
ID: 13998630
So what do you think of all that, Preece? This is kinda a hard picture to paint.  To keep this question as simple as possible, suppose I say that I want all links, which are in web pages contained in a browser control in Form1, to open in another browser control in Form2, as opposed to opening in Internet Explorer. Know what I mean?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 13998661
Your webbrowser has a event called NewWindow2 or something like that.  In that event it passes in a URL and Cancel parameter.  You would do something like this in that event:


Dim frm As New MyForm

frm.WebBrowser1.Navigate URL
Cancel = True





Where MyForm is the name of your current form with a webbrowser control on it.  Essentially, when it wants to open a new window, you spawn a new instance of your form and handle the navigation yourself.
0
 

Author Comment

by:John Account
ID: 13998730
Oh wow, thank God! Thanks, AzraSound--sounds like you're really onto something here!  I'm following you a bit, but just not completely. Could you please please elaborate a bit?  I would really appreciate it very much! Thanks.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 2000 total points
ID: 13998817
Aaah, its been too long.  Here is what it should look like:


Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
    Dim f       As New Form1
   
    f.WebBrowser1.RegisterAsBrowser = True
    Set ppDisp = f.WebBrowser1.Object
    f.Visible = True
End Sub



Reference:
http://support.microsoft.com/kb/q184876/
0
 
LVL 7

Expert Comment

by:Burbble
ID: 13998924
Here's the MSDN article on doing what you want (for VB6):

http://support.microsoft.com/kb/q184876/
0
 
LVL 7

Expert Comment

by:Burbble
ID: 13998937
Well, it's actually VB5, but it works for both.

The code is this:

Private Sub WebBrowser1_NewWindow2(ppDisp As Object,
                                   Cancel As Boolean)
   Dim frmWB As Form1
   Set frmWB = New Form1

   frmWB.WebBrowser1.RegisterAsBrowser = TRUE

   Set ppDisp = frmWB.WebBrowser1.Object
   frmWB.Visible = True
End Sub


Basically, it just loads another instance of your web browser form and redirects the click action to that one (instead of a new IE instance).
0
 

Author Comment

by:John Account
ID: 14000689
Wow...aside from one slight problem, this is truly amazing! Problem: Form1 loads and I'm aware that WebBrowser1.LocationURL, therein, worked as it was supposed to; however, that browser control IS NOT visible. The visible property is true, so I don't know why I can't see the browser control.  Any guesses why???
0
 

Author Comment

by:John Account
ID: 14000774
Ooops...Nevermind. I'm am so stupid. Stupid. Stupid. Stupid. LOL--My javascript was setting the location, etc--window.open('MyPage.php?user='+user+'&pwd='+pwd,'','height=650,width=200,left=500,top=10,...hence, it wasn't showing up on the form.

AzraSound, you are a great GREAT man. Apparently, you too, Burbble, but AzraSound was the quickest; hence the points.

Many thanks to you. I appreciate your help very VERY much. Wow...what a really great learning experience this has been. Invaluable!
0
 
LVL 7

Expert Comment

by:Burbble
ID: 14000952
Whoooooops, I didn't even see Azra's post there after I posted! (Must be going blind)

Glad we could help :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question