这有我做的TELNET控件中的PAINT代码,其中 GetUpdateRect 是取
当前窗口需要重画区域的....
procedure TOopsTelnet.WMPaint(var Message: TWMPaint);
var
DC: HDC;
PS: TPaintStruct;
rc, pr: TRect;
OldFont: THandle;
i: integer;
begin
if not GetUpdateRect(WindowHandle, rc, False) then Exit;
DC:=Message.DC;
if DC=0 then DC:=BeginPaint(WindowHandle, PS);
try
OldFont := SelectObject(DC, Font.Handle);
pr:=Rect(TermMargins, TermMargins-FFontSize.cy, TermMargins+FFontSize.cx, TermMargins);
for i:=0 to FRowCount-1 do begin
Inc(pr.Top, FFontSize.cy);
Inc(pr.Bottom, FFontSize.cy);
if (pr.Top>rc.Bottom)or(pr.Bottom<rc.Top) then Continue;
PaintLine(DC, pr, i);
end;
SelectObject(DC, OldFont);
finally
if Message.DC=0 then EndPaint(WindowHandle, PS);
end;
end;