Article View: pl.comp.lang.delphi
Article #335042Re: Problem z miganiem aplikacji
From: konsul41
Date: Mon, 06 Feb 2012 11:07
Date: Mon, 06 Feb 2012 11:07
88 lines
3588 bytes
3588 bytes
2 godziny i działa
efekt
http://www.kssoft.cba.pl/pg1.zip
starego nie usuwam dla porównania
kod:
private:
FBac : HBITMAP;
hdcMem : HDC;
cxClient : Integer;
cyClient : Integer;
procedure WMCREATE(var Message: TWMCreate); message WM_CREATE;
procedure WMEraseBkgnd(var Message: TWMEraseBkGnd); message WM_ERASEBKGND;
procedure WMSIZE(var Message: TWMSize); message WM_SIZE;
procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
procedure TMyPanel.WMCREATE(var Message: TWMCreate);
var dc : HDC;
Brush : HBrush;
rect : TRect;
begin
dc := GetDC(Self.Handle) ;
hdcMem := CreateCompatibleDC (dc) ;
Self.FBac:= CreateCompatibleBitmap (dc ,
2100,2500);//Self.Width,Self.Height);//Self.ClientWidth,Self.ClientHeight);
ReleaseDC (Self.Handle, dc) ;
SelectObject (hdcMem, FBac) ;
rect.Left:=0;
rect.Top:=0;
rect.Right:=Self.Width;
rect.Bottom:= Self.Height;
Brush:=GetStockObject (WHITE_BRUSH);
SelectObject (hdcMem, Brush) ;
FillRect (hdcMem, &rect, GetStockObject (WHITE_BRUSH)) ;
end;
procedure TMyPanel.WMEraseBkgnd(var Message: TWMEraseBkGnd);
begin
end;
procedure TMyPanel.WMSIZE(var Message: TWMSize);
begin
cxClient := TWMSize(Message).Width;
cyClient := TWMSize(Message).Height;
end;
procedure TMyPanel.WMPaint(var Message: TWMPaint);
var i : Integer;
DC : HDC;
rect : TRect;
begin
Inherited;
DC := GetDC(Self.Handle);
try
rect.Left:=0;
rect.Top:=0;
rect.Right:=2100;
rect.Bottom:= 2500;
FillRect (hdcMem, &rect, GetStockObject (WHITE_BRUSH)) ;
i:=0;
while i<main.FKontrolki.Count do
begin
main.ListaPGKomponent[TKontrolka(main.FKontrolki[i]^).komponent].DATA:=TKontrolka(main.FKontrolki[i]^).data;
main.ListaPGKomponent[TKontrolka(main.FKontrolki[i]^).komponent].narysujDC(Self.hdcMem);
inc(i);
end;
BitBlt(DC,0,0,Self.ClientWidth,Self.ClientHeight,Self.hdcMem,0,0,SRCCOPY);
finally
ReleaseDC(Self.Handle,DC);
end;
end;
to w zasadzie koniec.
Zmieniłem przodka TMyPanel z TPanel na TWinControl.
Efekty Miganie następuje przy obiekcie przesuwanym szybko i jest
akceptowalne, nawet przy dużej liczbie obiektów.
Dzięki Arivald za nakierowanie.
W przyszłości jak będzie naprawde dużo obiektów rysowanych pomyślę o
regionach.
Technical Details
Message-ID:
<4f2fb47e$0$1220$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailReferences:
<4f2d0c44$0$1229$65785112@news.neostrada.pl> <jgjc7n$558$1@news.dialog.net.pl> <4f2f80c2$0$1223$65785112@news.neostrada.pl> <jgo0ef$b6v$1@news.dialog.net.pl> <4f2f8a9f$0$1217$65785112@news.neostrada.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-02.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail From: <konsul41@wp.pl> Newsgroups: pl.comp.lang.delphi References: <4f2d0c44$0$1229$65785112@news.neostrada.pl> <jgjc7n$558$1@news.dialog.net.pl> <4f2f80c2$0$1223$65785112@news.neostrada.pl> <jgo0ef$b6v$1@news.dialog.net.pl> <4f2f8a9f$0$1217$65785112@news.neostrada.pl> Subject: Re: Problem z miganiem aplikacji Date: Mon, 6 Feb 2012 12:07:46 +0100 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Antivirus: avast! (VPS 120206-0, 2012-02-06), Outbound message X-Antivirus-Status: Clean Lines: 89 Message-ID: <4f2fb47e$0$1220$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 178.42.216.49 X-Trace: 1328526463 unt-rea-b-01.news.neostrada.pl 1220 178.42.216.49:2146 X-Complaints-To: abuse@news.neostrada.pl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit