Solved

Web Browser Control Question

Posted on 2002-05-01
11
163 Views
Last Modified: 2010-05-02
Hi.

I need some help clarifying the events associated with VB 6's Web Browser control. I have one, on a Form. This Form has a menu of its own and one of the top menu selections is "Favorites". The browser has basic back and forward buttons as you're probably aware.

My home button is coded for www.cnn.com. When I click on that, I get CNN online. I click around on the Favorites and work the browser to test it. There is one noticeable problem with the address bar - it doesn't always correctly display the URL. If I'm at one of my Favorites and I click the Home button, the last site I visited remains in the address bar.

What event do I need to check code on th get this browser to work as one would expect it to work (just like IE)?

Also, is there a way to add a history feature to this control?

Jim
0
Comment
Question by:jnowlin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 6983915
Try:

Private Sub WebBrowser_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If (pDisp Is WebBrowser.Object) Then
        txtURL.Text = URL
    End If
End Sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6983919
>>Also, is there a way to add a history feature to this control?

You could probably maintain this quite simply with an array
0
 

Author Comment

by:jnowlin
ID: 6984855
I wrote the Sub as you suggested but it didn't work. It looked as though it was an event associated with the browser control. I replaced txtURL.Text with my address bar control, which is cboAddress.Text.

Wait...
My control is named differently - I think it's brwBrowser.
So, do I understand correctly that your above code should work if I rename-
WebBrowser_DocumentComplete
to brwBrowser_DocumentComplete, it should then work?

I remember having this braincramp before. What you've suggested above sounds as if it's associated with one of this control's objects.

?
JimNowlin

Jim

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!

 
LVL 28

Expert Comment

by:AzraSound
ID: 6984875
Yes, the control has a DocumentComplete event that you should be able to see in the dropdown box listing the control's events in the code window of the VB IDE.
0
 

Author Comment

by:jnowlin
ID: 6984983
I got it this time AzraSound! In the process, I ran into another, more serious problem. This app crashes when I minimize the Form that the brwBrowser control is on with a run-time error 380: Invalid Property Value.
Which property? Since I minimize the Form and that's where there's a property incorrectly set. The border style is set to sizeable...
The Form has a maximize, minimize and restore in the upper right corner...
???
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6986046
What code do you have, if any, in your form's Resize event?
0
 

Author Comment

by:jnowlin
ID: 6987497
Hi AzraSound,

This is what't contained in my Form's Resize event:

Private Sub Form_Resize()
    cboAddress.Width = Me.ScaleWidth - 100
    brwWebBrowser.Width = Me.ScaleWidth - 100
    brwWebBrowser.Height = Me.ScaleHeight -   (picAddress.Top + picAddress.Height) - 100
End Sub

This Form came with VB as a template. I don't understand why there is a PictureBox contained within a ComboBox. Yet, it's there. The ScaleMode is set to twip. I've never altered any of these properties.

Jim
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6987554
Either add:

On Error Resume Next

at the top of the resize event, or do:

If Me.WindowState = vbMinimized Then Exit Sub

at the top of the resize event.
0
 

Author Comment

by:jnowlin
ID: 6989293
I tried both lines of code separately at the top of the Form's ReSize event and the program still crashes when the Form is minimized. "Invalid Property Value" - error 380

I wish this error msgbox would tell me more.

Should I try to trap this error, as in:

If Err.Number = 380 Then Exit Sub

??

I don't know what property of what object/control is set wrong or invalid. The application compiles without issuing any compile-time errors.
I suppose I could copy the code and remove this Form and add a new web browser Form. It's another option.

Bizarre.
Jim
0
 

Author Comment

by:jnowlin
ID: 6989725
Hold on...

It works. I was working with an older version of the app.
I'm sorry.
0
 

Author Comment

by:jnowlin
ID: 6989728
Thanks once again AzraSound.
I still would have liked to know which proerty on which control was invalid.

I'm off to pose the next question.

Jim Nowlin
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

751 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