1. Home
  2. Computing & Technology
  3. Delphi Programming

Cut a rectangle from an Image to Clipboard

By , About.com Guide

Cutting a graphic to the Clipboard is like copying it, but you also erase the graphic from the source.

~~~~~~~~~~~~~~~~~~~~~~~~~
procedure CutToClipboard
   (AnImage:TImage; ARect:TRect) ;
var b:TBitmap;
begin
  //first copy
  b:=TBitmap:Create;
  try
    b.Width := ARect.Width;
    b.Height := ARect.Height;
    CopyRect(Rect(0,0,b.Height,b.Width),
             AnImage.Canvas, ARect) ;
    Clipboard.Assign(b)
  finally
    b.Free
  end;
  //than cut
  with AnImage.Canvas do
   begin
    CopyMode := cmWhiteness;
    CopyRect(ARect, AnImage.Canvas, ARect) ;
    CopyMode := cmSrcCopy;
   end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Setting the Default Printer from code
« Get Filenames from Clipboard

Explore Delphi Programming
About.com Special Features

Reader's Choice Award Winners

What are the best instant messengers, apps, editors and more? You told us, for our 2010 technology awards program. More >

iPad Central

Is Apple's new tablet computer impractical, a must-have -- or both? We'll help you figure it out. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. Cut a rectangle from an Image to Clipboard

©2010 About.com, a part of The New York Times Company.

All rights reserved.