Solved

Webbrowser refresh issue

Posted on 2004-09-08
7
381 Views
Last Modified: 2013-12-25
Dear Experts,

I am using VB6 to add a webbrower control (zorder is 1) to a form.  In the form, there is a picture box and its zorder is 0.  After loading the webbrowser control with a html file (verified by the progressChange event of the webbrowser control), I change the visibility of the picture box to false.  The screen shows a blank page of the webbrowser control and then the content of the html.  How do I prevent the blank page ?

It is my first time to ask question here.  If my question is not clear, please feel free to clarify.  Thanks.
0
Comment
Question by:waycal
  • 4
  • 3
7 Comments
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 12004663
Try use DownloadComplete Event instead?

Private Sub WebBrowser_DownloadComplete()
  .... show your web browser visible here..
End Sub
0
 

Author Comment

by:waycal
ID: 12004695
Dear ryancys,

Thanks.  I have tried that before but it cannot help.

Whenever I show a picturebox on top of the webbrowser control and then turn the picturebox off.  The area of the webbrowser control overlapped by the picturebox will become blank and then redraw.  It generates a flickering and I want to prevent it.
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 12004715
>>The screen shows a blank page of the webbrowser control and then the content of the html
Maybe you can pause your application for a while using sleep api, like:

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Private Sub WebBrowser_DownloadComplete()

doevents
Sleep 1000 'pause 1 second
Picture1.visible = false
doevents

End Sub

?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:waycal
ID: 12004776
Dear ryancys,

It helps to prevent the blank page but the screen flickers when the picture1.visible = false.  How to avoid the flickering ?
0
 
LVL 50

Accepted Solution

by:
Ryan Chong earned 125 total points
ID: 12007099
Try apply LockWindowUpdate API to lock the window's update, to eliminate the flickering..

Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Private Sub WebBrowser_DownloadComplete()

doevents
LockWindowUpdate Me.hwnd
Sleep 1000 'pause 1 second
Picture1.visible = false
doevents
LockWindowUpdate 0

End Sub

If still facing flickering problem, try send a copy of your code to me, my email can be found in my profile.

regards
0
 

Author Comment

by:waycal
ID: 12012641
Dear ryancys,

Thanks.  By the way, just for my better understanding, what is the meaning of putting two "doevents" in the solution ?  What is the difference if I put them in different location (like after the LockWindowUpdate 0) ?
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 12012726
Hi waycal,

The DoEvents function surrenders execution of the macro so that the operating system can process other events. The DoEvents function passes control from the application to the operating system. Some instances in which DoEvents may be useful include the following:
* Hardware I/O
* Delay Loops
* Operating System Calls
* DDE Deadlocking
http://support.microsoft.com/default.aspx?scid=kb;en-us;118468

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingdoevents.asp

Rule on DoEvents
http:Q_21051743.html

>>What is the difference if I put them in different location (like after the LockWindowUpdate 0) ?
If you put doevents after LockWindowUpdate 0, the request (normally form redraw, etc) will be process only after the LockWindowUpdate 0, so depends on when you want the request to be processed first, then you put a line of doevents there. Hope this is clear ;-)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add text to end of existing text in file 16 70
vb6 connector to mongodb 2 84
clicking a shape in a frame array vb6 3 45
Send outlook email from VBS Script 2 30
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

778 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