怎么用Delphi做一个打印的功能只需要打印出窗体的所有东西即可窗体上有一个GroupBox,GroupBox上有几个TLabel和TComboBox和Button,窗体上还有一个TChart就这些东西了,我用窗体名直接 .Print; 打印出来的只有一个空的GroupBox,上边什么也没有,怎么能打印出GroupBox和它上边所有东西加TChart

解决方案 »

  1.   

    Declaration
    procedure PrintBitmap(X,Y: double; ScaleX, ScaleY: double; Bitmap: TBitmap);Category
    GraphicsDescription
    This method will draw Bitmap on the printer canvas at the point defined by (X,Y).
    The bitmap will be scaled by the factors ScaleX and ScaleY. (Example (Delphi) A scaling factor of 2 would draw each pixel in the bitmap as 2 pixels on the printer canvas.)这个过程不知道行不行,定义好位置,就可以打印了吧。
      

  2.   


    function SnapScreen(a,b,c,d:Integer):Integer;    //任意区域截图,参数为截图坐标
    var
       bmpscreen:Tbitmap;
        jpegscreen:Tjpegimage;
        FullscreenCanvas:TCanvas;
        dc:HDC;
        sourceRect, destRect: TRect;
    begin
        try
           dc:=getdc(0);
           fullscreencanvas:=Tcanvas.Create;
           fullscreencanvas.Handle:=dc;
           bmpscreen:=Tbitmap.create;
           bmpscreen.Width :=c-a;
           bmpscreen.Height :=d-b;
           sourcerect:=Rect(0,0,c-a ,d-b );
           destrect:= Rect(a,b,c,d);
           bmpscreen.Canvas.CopyRect(sourcerect,fullscreenCanvas,destrect);
           jpegscreen:=Tjpegimage.Create ;
          jpegscreen.Assign (bmpscreen);
           jpegscreen.CompressionQuality:=25;
           //jpegscreen.SaveToFile(ExtractFilePath(ParamStr(0))+'tmp.jpg');
           jpegscreen.SaveToFile('c:\tmp.jpg');
           FullscreenCanvas.Free;
           bmpscreen.Free;
           jpegscreen.Free ;
           ReleaseDC(0, DC);
       except
       end;
    end;打印图片即可,
      

  3.   

    我的Delphi7里怎么找不到   Tjpegimage 这个控件 呢