Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 415

Previous Page 414   Index   Next Page 416

Function Reference
Page 415 of 770
the logical bounding box can be calculated (the conversion is done automatically). However, non-
portable WMF files are device-dependent, they contain no size information. To get correct results,
the default size must be set with the function SetWMFDefExtent() beforehand. The parameters Width
and Height are passed to the member xExt, yExt of the structure METAFILEPICT which is required to
convert WMF files to EMF. The default size is 0, 0, that means the GDI calculates the size
automatically but mostly incorrect.
Because the GDI function SetWinMeatFileBits() is used to convert WMF files to EMF, WMF files are
not supported under Linux or UNIX.
Return Values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (Delphi):
// In this example, we have a paintbox (TPaintBox) on the form
// into which we paint an EMF file. The user can draw a rectangle when
// pressing the left mouse button, this rectangle is our cutting area.
// FView is a private variable of the type TRectL. Note that this
// rectangle must also be drawn in the OnPaint event of the paintbox.
procedure TForm1.PaintBoxMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var dc: HDC;
begin
dc := PaintBox.Canvas.Handle;
SetROP2(dc, R2_NOT);
SelectObject(dc, GetStockObject(NULL_BRUSH));
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
FView.Left
:= X;
FView.Top
:= Y;
FView.Right
:= X;
FView.Bottom := Y;
end;
procedure TForm1.PaintBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var dc: HDC;
begin
// The rectangle must be drawn twice, one time to delete the
// previous one, and the next time to draw the rectangle with the
// new size. There is no need to redraw the paintbox.
if (ssLeft in Shift) then begin
dc := PaintBox.Canvas.Handle;
SetROP2(dc, R2_NOT);
SelectObject(dc, GetStockObject(NULL_BRUSH));
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
FView.Right
:= X;
FView.Bottom := Y;
Rectangle(dc, FView.Left, FView.Top, FView.Right, FView.Bottom);
end;
 

Previous topic: GetLineWidth, GetLinkHighlightMode, GetLogMetafileSize

Next topic: GetLogMetafileSizeEx, GetMatrix