Solved

Webbrowser refresh issue

Posted on 2004-09-08
7
401 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
[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
  • 4
  • 3
7 Comments
 
LVL 52

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 52

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 52

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 52

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

739 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