Handle

Graphics32

TBitmap32.Handle

This following only applies to the VCL version of Graphics32:

property Handle: HDC; // read-only

Description

Provides device handle of the contained DIB.

This handle may be used in low-level Windows API calls or, for example, to attach a TCanvas object to TBitmap32:

var

  Canvas: TCanvas;

begin

  Canvas := TCanvas.Create; // create a new independent TCanvas object

  try

    Canvas.Handle := Bitmap32.Handle; // attach it to the Bitmap32 object

    Canvas.Pen.Color := clRed; // use standard TCanvas methods for drawing

    Canvas.Brush.Color := clGreen;

    Canvas.Ellipse(10, 10, 60, 40);

  finally

    Canvas.Free;

  end;

end;

Handle contains zero, if the bitmap is empty (width or height is zero), and its value can change after resizing.

This example is just a simple illustration of using the Handle property. For more information on using the TCanvas object with TBitmap32, see the Canvas property.

 

This following only applies to the CLX version of Graphics32:

property Handle: QPainterH; // read-only

Description

This provides a pointer to the current instance of the QPainterH in TBitmap32.

You can use this QPainter instance in external functions. However please notice, that the QPainter is not associated with the QPixmap of TBitmap32. You'll have to call QPainter_begin and QPainter_end manually to do so. See the QT docs for more information on this topic.

See Also

Canvas, TBitmap32