在delphi中将form保存为图像,包含滚动条隐藏的部分

根据TCustomForm.GetFormImage修改得来:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  ABitmap: TBitmap;
  i: Integer;
begin
  ABitmap := TBitmap.Create;
  if Self.HorzScrollBar.Visible then    
    ABitmap.Width := Self.HorzScrollBar.Range
  else
    ABitmap.Width := Self.ClientWidth;
  if Self.VertScrollBar.Visible then
    ABitmap.Height := Self.VertScrollBar.Range
  else
    ABitmap.Height := Self.ClientHeight;
  ABitmap.Canvas.Brush := Self.Canvas.Brush;
  ABitmap.Canvas.FillRect(ABitmap.Canvas.ClipRect);
  Self.Perform(WM_PAINT, ABitmap.Canvas.Handle, 0);
  for i := 0 to Self.ControlCount - 1 do
  begin
    with TControl(Self.Controls[i]) do
      if (Self.Controls[i] is TWinControl) and Visible then
        TWinControl(Self.Controls[i]).PaintTo(ABitmap.Canvas, Left, Top);
  end;
  ABitmap.SaveToFile('c:/1.bmp');
  FreeAndNil(ABitmap);
end;

阅读更多
文章标签: delphi integer c
上一篇双击GRID中线调整列宽
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭