TNGDibFormat

<< Click to Display Table of Contents >>

Navigation:  Data Formats >

TNGDibFormat

Previous pageReturn to chapter overviewNext page

TNGDibFormat class implements standard CF_DIB data format and allows to drag/receive device independed bitmaps. NG Drag&Drop use TBitmap standard Delphi type for working with bitmap data.

 

The class declares two methods: Data and Ref. Data method can be used to drag image data at the source side, while Ref method can be used to receive images at the target side. NG Drag&Drop declares special type alias CF.DIB to make user's code more readable:

 

NGDropSource.Add(CF.DIB.Data(b))
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  b: TBitmap;
begin
  b := Tbitmap.Create;
  try
    if C.Accept(CF.DIB.Ref(b)) then
      ShowBitmap(b);
  finally
    b.Free;
  end;
end);

 

Moreover, special methods are declared for working with bitmap data, which can simplify code even more:

 

NGDropSource.AddDib(b)
            .Execute;
 
NGDropTarget.Register(MyTargetPanel, procedure(C: TNGTargetContext)
var
  b: TBitmap;
begin
  b := Tbitmap.Create;
  try
    if C.AcceptDib(b) then
      ShowBitmap(b);
  finally
    b.Free;
  end;
end);