以前写的东西,给你看看:
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
procedure TfrmMain.InitFluxGuid;
var
i,j:integer;
m_rcClient:TRect;
begin
m_rcClient:=bmpGuid.Canvas.ClipRect;
bmpGuid.Canvas.Brush.Color:=clBlack;
bmpGuid.Canvas.FillRect(m_rcClient);
bmpGuid.Canvas.Pen.Style:=psSolid;
bmpGuid.Canvas.Pen.Color:=clBlue;
i:=m_rcClient.Left - 1;
while i<= (m_rcClient.Right) do
begin
Inc(i,13);
bmpGuid.Canvas.MoveTo(i, m_rcClient.top);
bmpGuid.Canvas.LineTo(i, m_rcClient.bottom);
end;
j:=m_rcClient.top - 1;
while j<= (m_rcClient.bottom) do
begin
Inc(j,13);
bmpGuid.Canvas.MoveTo(m_rcClient.left, j);
bmpGuid.Canvas.LineTo(m_rcClient.right, j);
end;
m_yPos := m_rcClient.bottom + 1;
m_yPreviousPos :=m_yPos;
end;
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
procedure TfrmMain.DrawFluxLine;
var
bkRect:TRect;
m_rcClient:TRect;
nX,J:integer;
begin
if bmpGuid=nil then Exit;
if m_yPos<=0 then m_yPos:=3;
m_rcClient:=bmpGuid.Canvas.ClipRect;
bkRect:=Rect(m_rcClient.right - 3, m_rcClient.top, m_rcClient.right, m_rcClient.bottom);
bmpGuid.Canvas.Brush.Color:=clBlack;
bmpGuid.Canvas.FillRect(bkRect);
BitBlt(bmpGuid.Canvas.Handle,0, 0, bmpGuid.Width, bmpGuid.Height,
bmpGuid.Canvas.Handle, 3, 0, SRCCOPY);
bmpGuid.Canvas.Pen.Style:=psSolid;
bmpGuid.Canvas.Pen.Color:=clBlue;
Dec(m_nFirstLinePos,3);
if(m_nFirstLinePos < 0) then
Inc(m_nFirstLinePos,13);
nX := m_rcClient.right - ((m_rcClient.right - m_nFirstLinePos) mod 13) - 1;
bmpGuid.Canvas.MoveTo(nX, m_rcClient.top);
bmpGuid.Canvas.LineTo(nX, m_rcClient.bottom);
j:=m_rcClient.top - 1;
while j<= (m_rcClient.bottom) do
begin
Inc(j,13);
bmpGuid.Canvas.MoveTo(bkRect.left - 3, j);
bmpGuid.Canvas.LineTo(bkRect.right, j);
end;
if m_yPreviousPos = (m_rcClient.bottom + 1) then m_yPreviousPos := m_yPos;
bmpGuid.Canvas.Pen.Color:=clRed;
bmpGuid.Canvas.MoveTo(m_rcClient.right - 11 - 3, pbGuid.Height - m_yPreviousPos);
bmpGuid.Canvas.LineTo(m_rcClient.right - 11, pbGuid.Height - m_yPos);
m_yPreviousPos := m_yPos;
pbGuid.Invalidate;
end;
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
procedure TfrmMain.pbGuidPaint(Sender: TObject);
begin
pbGuid.Canvas.Draw(0,0,bmpGuid);
end;