Solved

Is there a way to make a pageflipping form?

Posted on 1998-07-09
7
141 Views
Last Modified: 2010-04-04
I have an application which does a lot of manual painting (including filling the background on WM_ERASEBKGND). The problem is when I do things like changing the text of a label run-time, I get some flashing. Sometimes only the control itself, but sometimes the whole form. I would like to do some sort of pageflipping to avoid this. Any suggestions? My first thought was to change the form's device context to a memory-dc, and then copy the whole image to the screen, but it is read only... And would this be awfully slow?

/Pede
0
Comment
Question by:pede
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1357458
You could try the LockWindowUpdate function. Here is a snip from the description:

The LockWindowUpdate function disables or reenables drawing in the specified window. Only one window can be locked at a time.

BOOL LockWindowUpdate(

    HWND hWndLock       // handle of window to lock  
   );      
 
0
 
LVL 1

Author Comment

by:pede
ID: 1357459
I forgot to mention that I already use the LockWindowUpdate. It helps quite a bit, but it's not even close to perfect.

Sorry, my mistake.

/Pede

0
 
LVL 1

Author Comment

by:pede
ID: 1357460
What about only unlocking the window in the vertical retrace period? Like, LockWindowUpdate(Handle), do stuff, WaitforVerticalBlanc, LockWindowUpdate(0).

How do I wait for vertical retrace? It has to run on both 3.1, 95 and NT.

/Pede

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Accepted Solution

by:
Matvey earned 100 total points
ID: 1357461
pede, I think that the best thing to help you is some sources. You can find a unit at the following address that has a method to avoid the fliccering:

http://bes.trendline.co.il/torry/vcl/packs/yupack.zip

Look at the sources for the button and the drawing procedures at the end of the unit.

Cheers, bosism@netvision.net.il
0
 
LVL 1

Author Comment

by:pede
ID: 1357462
Well, this source definately works. But I was hoping for a more 'global' solution. This way I have to make a custom class (with quite a lot of code in it) for every control I use. I get the idea though, and I will reduce some of the worst flickering this way.

Cheers,

/Pede

0
 
LVL 1

Author Comment

by:pede
ID: 1357463
Actually I have another comment, if anybody finds this subject interesting. I wrote that the LockWindowUpdate()-method helped quite a bit. Well, in some ways it does, but sometimes it makes the whole client area flash when you unlock it! If the whole point is to make a flicker-free application, that's pretty bad ...
So far the only bulletproof way (that  I know of), is to do a lot of blitting  yourself. This is how it's done in the source suggested by Matvey.

/Pede

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1357464
You don't have to implement many time the same drwing procedure you see in the unit, and you don't necessary need classes for them. You can copy the methods to one unit and add it to the USES clause whenever you need drawing for your application.

Sorry if my answere wasn't helpful to you. I'll try my best to help you farther if you have problems,
Regards, Matvey
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

16 Experts available now in Live!

Get 1:1 Help Now