Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Flicker when changing forms/pages

Posted on 1999-07-09
13
Medium Priority
?
898 Views
Last Modified: 2010-05-18
I'm trying to switch between forms or pages in a pagecontrol tab.  I have images and buttons etc on these forms/pages but when I switch between them I get bad flicker.  I have tried using lockwindowupdate in various places which locks the screen fine, but flickers on unlocking (even my desktop flickers).  I've also tried loading the graphics using a canvas draw, and loadfromfile image etc.  Setting the brush.style to bsClear to try and overlay forms/pages but nothing seems to work.

I have come from a Toolbook background which is slow for a lot things but seems to handle jumping from screen to screen smoothly with no problem.  Does anyone know of a way in Delphi of imitating toolbook's page like abilities.  Speed is a partial issue here, but the main thing is to try and avoid flicker.

Thanks in advance.

Michael
0
Comment
Question by:mellams
[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
  • 3
  • 2
  • +3
13 Comments
 

Expert Comment

by:aacrg
ID: 1387316
Hi Michael
 
Would it be possible to draw the controls (with PaintToCanvas) on a bitmap, then changing the page and copy the bitmap on the TabSheet's canvas and then validate the whole DC? - I've never tested it, but perhaps other experts have made some expierence with that.

Regards, aacrg.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1387317
One thing you can try is setting the DoubleBuffered property to true:

MyPageControl.DoubleBuffered := True;

You might also set this for the Tab controls if this does not appear to make a difference.

Cheers,

Raymond,

0
 
LVL 10

Expert Comment

by:Lischke
ID: 1387318
The page control is quite a bad thing. I think either MS or Borland (or both) have made a very bad implementation of the control. You can't do very much to prevent flickering. You could, though, use a TabControl instead and make the page flip on your own. This way you have more control over the paint cycles...

Ciao, Mike
0
Independent Software Vendors: 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!

 
LVL 13

Expert Comment

by:Epsylon
ID: 1387319
Try

with <component> do
  ControlStyle := ControlStyle + [csOpaque];

Never used it myself, just found it somewhere.

Epsylon.

0
 

Expert Comment

by:GabeinOZ
ID: 1387320
Just a suggestion mate... I use panels instead of a page control in my app partially because of the flicker and partially because page controls make an application larger than the equivalent group of panels. When I need to transition between two pages I just use (panel).bringtofront and it comes through beautifully because the panel refreshes itself and all the child components within it.  I don't know if this will really do what you are asking for because you may actually be wanting the tabs but if you are just looking for a way to change 'pages'.... then panels is the way to go...

BTW...it IS a bit more difficult to work with the panels in the IDE of course but not enough to be a worry...

Gabe
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1387321
Its strang though, I have used Page Controls extensively in a bunch of apps, and never seen any flickering problems...

Cheers,

Raymond.

0
 

Author Comment

by:mellams
ID: 1387322
Thanks heaps everyone for those responses, I'm new to the exchange and its great to get this sort of feedback.

I've tried all those things suggested and alas, none seem to work.  It may be that I'm doing something wrong, but there doesn't seem to be a control over when Delphi chooses to repaint things..

Aacrg.  I had some sort of succes with pating straight to the canvas but I can't paint to the canvas of just the tabsheet, only the page control.. Is there a way to paint straight to the canvas of a tab?

Lischke.  I think it has something to do with the redrawing.  When using lockwindowupdate, it locks it fine and sometime (but not often) there is no flicker when it unlocks.  I get the feeling it is not waiting for the refresh run of the gun to finish.  Does anyone have the code to wait for the refresh period (I used to have it in ASM in TP7 but I've lost it :( ).

GabeinOz.  Which part of oz?  I tried the panels, and I still got flicker.  Apart from that it would have suited my purposes fine, I don't car about tabs or in fact anything taht makes it look like a standard windows app.  I'm a multimedia programmer (oxymoron?? :) ), so getting away from a windows look and losing the flicker is super important.  What I'm looking for is way to get 'pages' in a similar vein that you would get in Toolbook.  Even something as high level and limited as Director can leap from point to point seamlessly.

As to why I seem to get lots of flicker, its becuase I have lost of graphics in my app.  If you just fill the pages/forms or whatever with buttons and lists and fields, you don't see a flicker, obviously I need to change something to compensate for the large graphics being used.  I'm sure Delphi has more than enough grunt to do that, its just a matter of finding the trick.  Does anyone have any games programming experience in which controlling flicker ertc would be par for the course.

Once again, thanks everyone for your help...

Michael
0
 

Expert Comment

by:GabeinOZ
ID: 1387323
Michael
Im on the Central Coast just north of sydney...
I am also a multimedia programmer in Delphi which is very difficult as I'm sure you know....I've fought very hard against flicker and such things especially since we distribute to a min spec of 166 with 32 ram.  I've optimized the panel situation so I have absolutely no flicker my panels are 640X355 and they all have client aligned images as well as the rest of the 640X480 is covered by static images with avis running all over the place.  How exactly did you use the panels?  I've found that if I load the images first and then bring the panel to front (sometimes throwing in an application.processmessages; ) I never get flicker.  You might have to play with the positioning of the bringtofront line as secondary code affects the repainting more than anything.  I try to load the images, then do major processing things, then bringtofront the panel, then any minor code.  Play with it a bit...thats the one thing I'm sure of when it comes to multimedia delphi programming because our programme is as far from windows as its possible to get.

Let me know if you need any more clarification.

Cheers
Gabe
0
 

Author Comment

by:mellams
ID: 1387324
Hi GabeinOz,

I'm down in sunny (well for some of the day) Melbourne.  Its a shame Delphi doesn't have a few simple to use Multimedia bits and pieces, since the rest of the language seems nice and powerful and slots in with the Windows API better than most.  Thanks for the help.  I basically just placed the panels on top of each other, each with an image (timage) and tried both bringing to front and hide/showing.  I'll have a bit more of a play.  Is an image componant the way to go, or should I load a tpciture and draw to the canvas?  And did you have to use lockwindowupdate?  I can't help feeling there is something simeple I'm not doing, its only the image itself that is flickering (even when taking all the other steps suggested by eveyone else)... Anyway I'll see how I go (I've had to stop and work on another job :( ), but I'll write back soon.

Thanks

Michael
0
 

Expert Comment

by:GabeinOZ
ID: 1387325
Michael, yes I totally agree on the delphi/multimedia points....I've had a bit of a whinge all over the net over the last month or so because I was having such problems trying to play a simple avi with sound but I got that one worked out finally.  

Anyway, back to your problem.  Forget about the canvas...just use a timage component....Ill write a little sample project for ya and get back to ya...give me a bit

Gabe
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1387326
Hi Gabe - How did you get your AVI playing to work out

(I know, off topic...)

Cheers,

Raymond.

0
 

Expert Comment

by:GabeinOZ
ID: 1387327
Michael-ok I got a test demo here for ya about as flicker free as it gets....its 1.6 meg if you want me to send it to ya send me an email and I will reply to it

gabrieln@futureschool.com.au

Raymond-actually I got in touch with the creator of the aviplayer in the dream companies freeware package, Sergey Kostinsky and he helped me out with the problems I was having with it and I worked out a few workarounds for the other problems he couldnt and now it works pretty damn good.  :)

Late
Gabe
0
 

Accepted Solution

by:
GabeinOZ earned 800 total points
ID: 1387328
I've sent you the source and project.  Using panels is the way to go in multimedia programs.  If you add in a call to the doublebuffering property of the panel it works even smoother.

Gabe
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

730 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