Solved

Webbrowser refresh issue

Posted on 2004-09-08
7
362 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 49

Expert Comment

by:Ryan Chong
Comment Utility
Try use DownloadComplete Event instead?

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

Author Comment

by:waycal
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
>>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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:waycal
Comment Utility
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 49

Accepted Solution

by:
Ryan Chong earned 125 total points
Comment Utility
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
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now