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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flickering TImage component when drawing on it

Status
Not open for further replies.

valmierietis

Programmer
Sep 22, 2005
2
LV
Hi!
I want to draw rectangles on TImage component imgMain, this is it's `onMouseMove` even:

procedure TfrmMain.imgMainMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
imgMain.Canvas.Pen.Color:=clWhite;
imgMain.canvas.Rectangle(X-10,Y-10,X+10,Y+10);
end;

I wrote in at home, everything was perfect. Then I brought it to my work's computer and I changed nothing, just re-compiled it. And now it flickers when moving mouse over that component (as if it tried to redraw everything or something like that). Why is it so? What to do? Can it be so because at home there is Delphi 7, but at work - Delphi 6? How can I make it normal?

Thank you!
 
hi,
usualy i use

in the form create add :
DoubleBuffered:=true; //this help a lot

also, recently i found that this proc should help (but i havent tryies that much). as is, this should prevent form flicker.. maybe it can be implemented for Ttimage, maybe not.. anyhow its good to know

procedure Tform1.WMEraseBkgnd(var m : TWMEraseBkgnd);
begin
m.Result := LRESULT(False);
end;

but.. in any case, its better to draw on an invisible component and once everything is draw.. copy it to the visible component.. thats the real way to avoid flicker

hope this help
jb
 
Wow, thanks, this `DoubleBuffered:=true;` helped instantly, I had to do nothing else! Thanks a lot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top