Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1425
  • Last Modified:

How do I control WebBrowser attributes (bg color; scroll bars; etc)

I am using WebBowser component in shdocvw.dll to display animated gif inside a form.  I would like to simply display the gif, without any scroll bars, borders and have the background color match the form.
If there is another way to display the gif, I'm open for suggestions.

WebBrowser1.Navigate "file.gif"

Thanks,

Russ
0
RUSS_EMI
Asked:
RUSS_EMI
  • 3
  • 3
  • 2
  • +1
1 Solution
 
AzraSoundCommented:
>>without any scroll bars

the most common workaround is to place the webbrowser control inside of another container, and position it such that the scroll bars are hidden, such as a frame or picturebox control.


>>and have the background color match the form

this would require that you edit the gif to have the background color you desire.
0
 
KDivadCommented:
>>and have the background color match the form

I thought he meant the background color of the webbrowser control? Just in case, here's how to do that easily:

WB.Navigate "about:blank" 'Clear the last document first!
WB.Document.Write "<body bgcolor=#C0C0C0><img src=" & Chr$(34) & "file.gif" & Chr$(34) & ">"
0
 
KDivadCommented:
As Azra (do you mind "Azra"?) said, you will need to put the WB control inside another container (such as a picbox) and resize it just right to hide the scrollbars and border.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wsh2Commented:
<ping>
0
 
wsh2Commented:
From Vb2TheMax:
-------------------------------------
The standard PictureBox control doesn't support the Animated GIF graphic format. However, you can display these images by using a WebBrowser control:

WebBrowser1.Navigate "c:\Images\Animated.Gif"

The only problem of this technique is that the WebBrowser control also displays a vertical and/or horizontal scroll bar. You can hide these scrollbars, if you wish, simply by putting the WebBrowser control inside a PictureBox control, whose width and height is smaller than the WebBrowser control. The following code snippet does that programmatically via the Add method of the Controls collection (requires VB6):

Private Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" _
    (ByVal nIndex As Long) As Long
Private Const SM_CXVSCROLL = 2
Private Const SM_CYHSCROLL = 3

' create a new PictureBox
Dim picBox As PictureBox
Set picBox = Controls.Add("VB.PictureBox", "picBox")

' resize the picture box so that it can hide the
' WebBrowser's scroll bars    
With WebBrowser1
    picBox.Move .Left, .Top, .Width - ScaleX(GetSystemMetrics(SM_CXVSCROLL), _
        vbPixels), .Height - ScaleY(GetSystemMetrics(SM_CYHSCROLL), vbPixels)
    ' move the WebBrowser inside the picture box
    Set WebBrowser1.Container = picBox
    ' ensure that the WebBrowser's border isn't visible
    .Move -ScaleX(2, vbPixels), -ScaleY(2, vbPixels)
End With

' all controls are created invisible
picBox.Visible = True

0
 
RUSS_EMIAuthor Commented:
As I have variable size animated gifs to display wsh2's answer is most correct, but it doesn't address the background color issue.
I tried using .document.write "<...>" and got a run time error 91.  "Object or With variable block not set".
Please advice.

Thank you,

Russ
0
 
RUSS_EMIAuthor Commented:
Ammending my last comment;
I can't seem to center the gif and minimize the area around it. This is in addition to the color question.
Russ
0
 
AzraSoundCommented:
try:

WebBrowser.Navigate "about:blank"
Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
   DoEvents
Loop
WebBrowser.Document.write strHTML



>>do you mind "Azra"?

either that or "sexy", whichever you prefer...
0
 
RUSS_EMIAuthor Commented:
Azra or "Sexy" (as you prefer);
   The more complicated solution of wsh2 didn't work, because of the inability to center and color correctly.
Thank you for your quick response.

Russ
0
 
KDivadCommented:
I'm afraid I'd need to know a little more about you before I'd use "sexy"! <grin>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now