[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to prevent flickering of graphics

Posted on 2002-04-23
5
Medium Priority
?
342 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
[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
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 200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

650 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