AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein FreePascal [gelöst] Lazarus: StringGrid drucken
Thema durchsuchen
Ansicht
Themen-Optionen

[gelöst] Lazarus: StringGrid drucken

Ein Thema von Kralle · begonnen am 18. Feb 2015 · letzter Beitrag vom 19. Feb 2015
 
Kralle

Registriert seit: 31. Okt 2004
Ort: Bremerhaven
355 Beiträge
 
Delphi XE7 Professional
 
#21

AW: Lazarus: StringGrid drucken

  Alt 18. Feb 2015, 16:25
Schmeiss bitte einmal Deine gesamte Unit hoch.
Also, ich bin jetzt mal Deinen Weg hiermit gegangen:

Delphi-Quellcode:
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
      Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
         Grids, Types, Windows, Printers;

type

         { TForm1 }

      TForm1 = class(TForm)
                  Button1: TButton;
                  StringGrid1: TStringGrid;
                  procedure Button1Click(Sender: TObject);
      private
            { private declarations }
      public
            { public declarations }
      end;

var
      Form1: TForm1;

implementation

{$R *.lfm}

procedure PrintGrid(sGrid: TStringGrid; sTitle: string);
var
  X1, X2: Integer;
  Y1, Y2: Integer;
  TmpI: Integer;
  F: Integer;
  TR: TRect;
begin
  Printer.Title := sTitle;
  Printer.BeginDoc;
  Printer.Canvas.Pen.Color := 0;
  Printer.Canvas.Font.Name := 'Times New Roman';
  Printer.Canvas.Font.Size := 12;
  Printer.Canvas.Font.Style := [fsBold, fsUnderline];
  Printer.Canvas.TextOut(0, 100, Printer.Title);
  for F := 1 to sGrid.ColCount - 1 do
  begin
    X1 := 0;
    for TmpI := 1 to (F - 1) do
      X1 := X1 + 5 * (sGrid.ColWidths[TmpI]);
    Y1 := 300;
    X2 := 0;
    for TmpI := 1 to F do
      X2 := X2 + 5 * (sGrid.ColWidths[TmpI]);
    Y2 := 450;
    TR := Types.Rect(X1, Y1, X2 - 30, Y2);
    Printer.Canvas.Font.Style := [fsBold];
    Printer.Canvas.Font.Size := 7;
    Printer.Canvas.TextRect(TR, X1 + 50, 350, sGrid.Cells[F, 0]);
    Printer.Canvas.Font.Style := [];
    for TmpI := 1 to sGrid.RowCount - 1 do
    begin
      Y1 := 150 * TmpI + 300;
      Y2 := 150 * (TmpI + 1) + 300;
      TR := Types.Rect(X1, Y1, X2 - 30, Y2);
      Printer.Canvas.TextRect(TR, X1 + 50, Y1 + 50, sGrid.Cells[F, TmpI]);
    end;
  end;
  Printer.EndDoc;
end;




procedure TForm1.Button1Click(Sender: TObject);
begin
    PrintGrid(StringGrid1, 'Print Stringgrid');
end;

end.
Und es gibt wieder ein "SIGSEGV"
OS: Windows 10 Professional, Delphi XE7 Pro SP1 +(Mobilpack & FireDAC)
  Mit Zitat antworten Zitat
 

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz