Solved

How to prevent flickering of graphics

Posted on 2002-04-23
5
311 Views
Last Modified: 2012-08-14
I'm writing a card game in VB 6.0 for fun, using cards.dll - the Microsoft card game DLL that games like Hearts and Solitaire use.

My forms use AutoDraw=False and ClipControls=False, and use the Form_Paint() method to update the screen when necessary via Refresh. The problem is that the screen flickers sometimes during the update. Otherwise, it works great. What's the problem?
0
Comment
Question by:dplambert
5 Comments
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 6962738
In general flickering is noticeable when you update something that you don't need to. Try just redrawing those things that have actually changed. Another tehnique is to hide everything on your form, make the changes, then show it again. From the users perspective, they don't see anything get hidden because you never release the processor to hide the stuff, so it just looks like everything changed at once.

Zaphod.
0
 
LVL 18

Accepted Solution

by:
mdougan earned 50 total points
ID: 6962808
AutoRedraw to True might help as well, because then VB updates the image buffer first, and then pages it into the form for a faster refresh.
0
 
LVL 3

Author Comment

by:dplambert
ID: 6962899
I changed ClipControls=True and it works great. No more flickering.
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6963034
Often when updating a Treeview, ListView etc. a lot of flickering takes place. To prevent this create a class called Freeze and use it in your form like this: Dim Freeze as New Freeze Freeze.Form Me when the scope goes out range the class will destroy itself and everything will be back to normal.



'declare function to stop window flickering when loading / updating forms
Private Declare Function LockWindowUpdate Lib _
"USER32" (ByVal hwndLock As Long) As Long

Option Explicit

Public Sub Form(pForm As Form)
    LockWindowUpdate pForm.hWnd
End Sub

Private Sub Class_Initialize()
    'check who called the class
End Sub

Private Sub Class_Terminate()
    LockWindowUpdate False
End Sub

The above code is taken from

http://www.freevbcode.com/ShowCode.ASP?SearchString=flickering%20stop&ID=141

0
 
LVL 3

Author Comment

by:dplambert
ID: 6972650
Everyone had valid comments. I most likely will use the hide/show before releasing the processor like the first comment reads if it's still an issue...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

707 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

17 Experts available now in Live!

Get 1:1 Help Now