Autor Beitrag
jensenwb
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: So 06.08.06 20:54 
ein was ist bei mir anders als bei dir.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm2.FormKeyPress(Sender: TObject; var Key: Char);
 var
  img: TBitmap;
  imgaus: TBitmap;
begin
  inherited;
  if Key = 'z' then
    begin
      img := TBitMap.Create;
      Form2.BorderStyle := bsSingle;
      img := Form2.GetFormImage;
      Form2.BorderStyle := bsDialog;
      img.SaveToFile(ExtractFilePath(Application.ExeName)+'Test.bmp');
      imgaus := TBitMap.Create;
      imgaus.LoadFromFile('test.bmp');
      Printer.BeginDoc;
      Printer.Canvas.Draw(0, 0, imgaus);
      Printer.EndDoc;
    end;
end;


Versuch es auch mal mit dem inherited, vielleicht liegt es ja daran.
PatrickJ Threadstarter
Hält's aus hier
Beiträge: 12

Win XP
Delphi 2005
BeitragVerfasst: Mo 07.08.06 16:48 
Hab jetzt rausgefunden, woran es lag. In der Unit1 stand:

ausblenden Delphi-Quelltext
1:
2:
3:
var
  Form1: TForm1;
  Form2; TForm2;


Die Deklaration der Variable Form2 hat die Probleme verursacht, für die Nutzung der Form2 reicht uses ... unit2 aus.
Ich kann nun Form2.Print zum Drucken einsetzten. :D


Hat vielleicht einer ne Idee, wie man die Auflösung verbessern kann? :?:

_________________
Stärkt die Gemeinschaft in der Entwickler Ecke und macht mit beim Gemeinschaftsprojekt EE-Lemmings!
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mi 09.08.06 10:02 
Hallo,
habe auch mal folgendes versucht, wie ich aus den Beiträgen zuvor entnehmen konnte:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
var
  img: TBitmap;
  imgaus: TBitmap;
begin
  img := TBitMap.Create;
  img := Form1.GetFormImage;
  img.SaveToFile(ExtractFilePath(Application.ExeName)+'Test.bmp');
  imgaus := TBitMap.Create;
  imgaus.LoadFromFile('test.bmp');
  printer.orientation:=polandscape;
  Printer.BeginDoc;
  Printer.Canvas.Draw(0, 0, imgaus);
  Printer.EndDoc;


Jetzt druckt er mir mein Formular im Querformat, leider nur sehr klein, wie kann ich also angeben, wie groß er das Bild ausdrucken soll.
Größe des Ausdrucks zur Zeit ca 2*5 cm.

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!
Bronstein
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 578
Erhaltene Danke: 1

WIN XP
Delphi 6 / Delphi 2006 / Delphi XE
BeitragVerfasst: Mi 09.08.06 10:29 
Hat sich erledigt, habe folgenden Code gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  
var
Bmp : TBitmap;
begin
  BMP := TBitmap.Create;
  BMP.Assign(Form1.GetFormImage);
  printer.orientation:=polandscape;
  Printer.BeginDoc;
  Printer.Canvas.StretchDraw(RECT(0,0,Printer.PageWidth,Printer.PageHeight), BMP);
  Printer.EndDoc;


Jetzt habe ich aber ein neues Problem:

Kann ich anstatt der kompletten Form auch angeben dass er mir ein TabSheet ausdruckt, wie bekomme ich also ein TabSheet zu einem Image. Habe mal folgendes Versuch, jedoch ohne erfolg:
ausblenden Delphi-Quelltext
1:
BMP.Assign(Form1.TabSheet4.Brush.Create.Bitmap);					


Hier bekomme ich aber nur ein weißes Blatt aus dem Drucker

_________________
Es gibt keine dummen Fragen nur dumme Antworten!!!