| Code: |
| Mainform.SimpleGraph.Print(PrintPreview1.Canvas, Rect(0, 0, Mainform.SimpleGraph.GraphBounds.Right, (Mainform.SimpleGraph.GraphBounds.Bottom))); |
| Code: |
| with PrintPreview1 do
SimpleGraph.Print(Canvas, Rect(0, 0, PagePixels.X, PagePixels.Y)); |
| Code: |
| procedure MainForm.PreviewGraph;
begin PrintPreview.BeginDoc; try SimpleGraph.Print(PrintPreview.Canvas, PrintPreview.PageBounds); finally PrintPreview.EndDoc; end; end; |
| Code: |
| procedure TGraphNode.DrawBackground(Canvas: TCanvas);
var ClipRgn: HRGN; Bitmap: TBitmap; Graphic: TGraphic; begin if Background.Graphic <> nil then begin ClipRgn := CreateClipRgn(Canvas); try SelectClipRgn(Canvas.Handle, ClipRgn); try Graphic := Background.Graphic; if (Graphic is TMetafile) or (Graphic is TIcon) or Graphic.Transparent then Canvas.FillRect(BoundsRect); Background.OnChange := nil; try if (Graphic is TMetafile) and (GetObjectType(Canvas.Handle) = OBJ_ENHMETADC) and ((BoundsRect.Left >= Screen.Width) or (BoundsRect.Top >= Screen.Height)) then begin // Workaround Windows bug! Bitmap := TBitmap.Create; try Bitmap.Transparent := True; Bitmap.TransparentColor := clFuchsia; Bitmap.Canvas.Brush.Color := clFuchsia; Bitmap.Width := BoundsRect.Right - BoundsRect.Left; Bitmap.Height := BoundsRect.Bottom - BoundsRect.Top; Bitmap.Canvas.StretchDraw(Rect(0, 0, Bitmap.Width, Bitmap.Height), Graphic); Canvas.Draw(BoundsRect.Left, BoundsRect.Top, Bitmap); finally Bitmap.Free; end; end else Canvas.StretchDraw(BoundsRect, Graphic); finally Background.OnChange := BackgroundChanged; end; finally SelectClipRgn(Canvas.Handle, 0); end; finally DeleteObject(ClipRgn); end; Canvas.Brush.Style := bsClear; end; end; |
| Code: |
| function TSimpleGraph.GetAsMetafile: TMetafile;
var I: Integer; GraphRect: TRect; MetaCanvas: TMetafileCanvas; v,w: TSize; begin GraphRect := GraphBounds; Result := TMetafile.Create; Result.Width := GraphRect.Right - GraphRect.Left; Result.Height := GraphRect.Bottom - GraphRect.Top; MetaCanvas := TMetafileCanvas.Create(Result, 0); try // Workaraound for Windows-bug SetViewportOrgEx(MetaCanvas.Handle, GraphRect.Left, GraphRect.Top, nil); SetMapMode(MetaCanvas.Handle, MM_Lometric); GetWindowExtEx(MetaCanvas.Handle, w); GetViewPortExtEx(MetaCanvas.Handle, v); SetMapMode(MetaCanvas.Handle, MM_Anisotropic); SetWindowExtEx(MetaCanvas.Handle, w.cx, w.cy, nil); SetViewPortExtEx(MetaCanvas.Handle, v.cx, -v.cy, nil); for I := 0 to Objects.Count - 1 do with Objects[I] do if IsLink then Draw(MetaCanvas); for I := 0 to Objects.Count - 1 do with Objects[I] do if not IsLink then Draw(MetaCanvas); finally MetaCanvas.Free; end; end; |
output generated using printer-friendly topic mod. All times are GMT