delphi小程序抓图后自动保存到指定的目录中 并且以时间来命名 

解决方案 »

  1.   

    procedure Tfrm.A_BitmapExecute(Sender: TObject);
    var
       ABitmap: TBitmap;
    begin
      if not SaveDialog1.Execute then exit;
      ABitmap := TBitmap.Create;
      try
       SampleGrabber1.GetBitmap(ABitmap);
       ABitmap.SaveToFile(SaveDialog1.FileName);
      finally
        ABitmap.Free;
      end;
    end;我是这样写的 想实现的是 点击一下保存键 自动就保存到指定的位置了 而且保存的图片文件名是当前的时间 请问该怎么修改
      

  2.   

     ABitmap.SaveToFile(SavePath + FormatDateTime('yyyymmddhhmmss', Now) + '.bmp');SavePath是个变量,保存“指定的位置”,可以做到界面上,让用户去填,当然要程序默认一个先~
      

  3.   


    抓图用拷屏BitBlt
    procedure TForm1.Button3Click(Sender: TObject);
    var
      BMP:TBitmap;
      fname:string;
      ScreenDC:HDC;
    begin
      bmp := TBitmap.create;
      bmp.Width := 1024;
      bmp.Height := 768;
      ScreenDC := GetDC(0);
      try
        BitBlt(Bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,ScreenDC,0,0,SRCCOPY);
      finally
        ReleaseDC(0,ScreenDC);
      end;
      fname := ExtractFilePath(ParamStr(0))+
               FormatDateTime('yyyymmddhhmmss',now)+'.bmp';
      bmp.SaveToFile(fname);
      bmp.Free;
    end;