Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flickering CView 1

Status
Not open for further replies.

MarcoMB

Programmer
Oct 24, 2006
61
IT
Hi, i'm a beginner developer in Visual C++ 6.0, and i'm trying to create a simple paint application.The problem i must effort is to evitate the view flickering derived from the Invalidate() during the WM_MOUSEMOVE message placed to refresh the view while the user is positioning the shapes.
In other words the usr pick a shape(es a circle), moves it in the view and double-click to position the shape that will be added to a CObArray.During the positioning we need to refresh the View to evitate the wake or trace left by the shape.This result in a flickering images proportional to many object in the array have to be continuosly redraw.
Can someone help me?
 
Once you've selected your object, make offscreen bitmaps of everything behind it, your object and everything in front of it. That way it's always exactly 3 bitblts instead of one for each object in the array.

The other thing is to only invalidate what's absolutely necessary. When moving your rectangle, remember the previous position. Invalidate that rectangle and the new rectangle.

These two things should reduce or eliminate your flickering.
 
thanks for help...i resolved the problem simply using the InvalidatRgn with the past and current position of the object as you suggested...i haven't understood very well what you meaning with off-screen bitmaps...can you give me some explanations of what offscreen bitmaps are?thanks a lot
 
Er, haven't actually done this in years... Let me try to explain roughly...

When the object is selected (mouse click or whatever), do this:

You create a DC (device context) compatible to your desktop "window." Create and assign a bitmap. Draw your background and the objects behind the selected object. Now when you destroy the DC, your bitmap should contain a graphical representation of all those objects.

Do it again with the objects in front of the selected object.

When the Paint request comes through, you just BitBlt from the "behind" bitmap, draw the object, and BitBlt from the "infront" bitmap.

Consistant 3 operations instead of one for each object in the array. Slightly wasteful when you've only got 1 or 2 objects; incredible speedup when you've got dozens!

I suppose you could even leave the appropriate bitmap handles null if there's nothing "behind" or "in front" and that would reduce the waste.
 
thanks a lot Miros for your help...i have to work with your suggeriments...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top