Solved

Webbrowser refresh issue

Posted on 2004-09-08
7
394 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 51

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 51

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
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!

 

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 51

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 51

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

679 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