从前人家的答案,看一下吧
procedure PrintPanel(Panel: TPanel;
SLeft, STop, SWidth, SHeight, Left, Top: LongInt;
HScale, ZScale: Real);
var
WJDC: HDC;
WJBitMap: TBitMap;
Info: PBitMapInfo;
InfoSize, ImageSize: DWORD;
Image: Pointer;
begin
Printer.begin
Doc;
WJBitMap := TBitMap.Create;
WJBitMap.Width := SWidth;
WJBitMap.Height := SHeight;
WJDC := GetDC(Panel.Handle);
BitBlt(WJBitMap.Canvas.Handle, 0, 0, SWidth, SHeight, WJDC, SLeft, STop, SRCCOPY);
ReleaseDC(Panel.Handle, WJDC);
GetDIBSizes(WJBitMap.Handle, InfoSize, ImageSize);
GetMem(Info, InfoSize);
GetMem(Image, ImageSize);
GetDIB(WJBitMap.Handle, 0, Info^, Image^);
StretchDIBits(Printer.Canvas.Handle, Left, Top, Round((Panel.Width - 2) * HScale),
Round((Panel.Height - 2) * ZScale), 0, 0, Info^.bmiHeader.biWidth,
Info^.bmiHeader.biHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);
FreeMem(Image, ImageSize);
FreeMem(Info, InfoSize);
WJBitMap.Free;
Printer.EndDoc;
end;