Hi Chris, some of this may be of use to you.

One way of minimising screen flicker is by using SetWindowRgn, to stop
Windows updating the area of the screen where you're doing a lot of work
(ie. doing this with your control might enable you to not have to draw
to a bitmap).

procedure TMyForm.WindowStuff;
var MyRegion, MyFormRegion: HRGN;
begin
    GetWindowRgn(MyForm.Handle, MyFormRegion);
    MyRegion := CreateRectRgn(MyLeft, MyTop, MyWidth, MyHeight);  // or
use CombineRgn with MyFormRegion
    SetWindowRgn(MyForm.Handle, MyRegion, False);  // Tell Windows not
to update this region of the screen any more, not until you're finished
with it.

If you were doing several things in a row that would cause multiple
flicker due to having the window recreated more than once (which you're
not, I think, but I include the code for completeness), you can bundle
them together by creating a private variable Reshowing: boolean, and
doing the following

    Reshowing := true;
    DestroyHandle;  // Destroys the window, so we only get one flicker
    ...  // Do things that would call RecreateWnd, eg. change
BorderIcons and/or BorderStyle
    CreateHandle; // Recreates the window, but doesn't display it yet
    ... // Other window manipulation
    UpdateControlState; // Now the window is redisplayed
    Reshowing := false;

(You need the variable Reshowing, because when the window is recreated,
FormShow will run again
procedure TMyForm.FormShow(Sender: TObject);
begin
    if Reshowing then Exit else inherited;
end;)

Once you've finished updating, you return drawing control back to
windows

//  Restore the drawable area of the Form to the entire window
    SetWindowRgn(MyForm.Handle, MyFormRegion, true);
//  Release control of form drawing back to Windows
    SetWindowRgn(MyForm.Handle, 0, false);
//  Delete temporary regions.  Warning: MyFormRegion belongs to Windows
now, so don't delete it!
    DeleteObject(MyRegion);
end;

Hope that helps.

Cheers,

Carl Reynolds                      Ph: +64-9-4154790
CJN Technologies Ltd.             Fax: +64-9-4154791
[EMAIL PROTECTED]                DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/

> -----Original Message-----
> From: Chris Crowe [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 27, 1999 8:16 AM
> To:   Multiple recipients of list Delphi
> Subject:      [DUG]:  Drawing Speed
> 
> I am writing a custom scheduling control, which does a lot of drawing
> to the screen.
> 
> Do stop flicker I have created a bitmap the size of the client area of
> the control. I then draw the interface to the bitmap, and then I draw
> the bitmap to the screen using Canvas.Draw(0,0, MyBitmap);
> 
> I found this accetable when the control is small, but if it is say
> getting up to around 800 * 600 it takes a fair amount of time to draw.
> I have a timing component which states it takes 0.091 seconds on
> average to draw the image at the large screen size. You might say that
> it is quite fast. I suppose it is. But the control must support
> selecting of rows and scrolling of the window, much like a listbox. 
> 
> It is very much designed around the outlook/schedule plus style of
> their day view for their scheduling. 
> 
> Is there a faster way of drawing to the screen?, I have to draw to the
> bitmap becuase if I do not the screen flickers rather badly.
> 
> Outlook draws very fast, and I assume my routines are quite optimized
> but obviosly not enough. So is there a better way, am I better to use
> BitBlt to draw to the screen than the Canvas.Draw()?
> 
> Any other speed increasing tips would be greatly appreciated...
> 
> ps: Does anyone know of a profiler that will profile a component,
> instead of the application?
> 
> Chris
> 
> 
> Christopher Crowe (Software Developer)
> Microsoft MVP, MCP
> 
> Adrock Software
> Byte Computer & Software LTD
> P.O Box 13-155 
> Christchurch
> New Zealand
> Phone/Fax (NZ) 03-3651-112
> 
> ----------------------------------------------------------------------
> -----
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz

application/ms-tnef

Reply via email to