Autor Beitrag
Andi1982
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Di 22.06.04 09:29 
Hallo,
ich habe eine function "FormularSaveScreenShot". diese hat bisher wunderbar funktioniert. Allerdings habe ich eine abfrage eingebaut in der Checkbox2 abgefragt wird. Nur sagt er dann beim compilieren "undefinierter Bezeichner Checkbox2". Soweit ich weiß liegt es an der definition der Function.

Aber wie muss ich die ändern, oder wo muss ich die bekannt machen, damit sie auf die Objekte meiner Form zugreifen kann??

Hier mal der Quellcode...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, ExtCtrls, jpeg;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Button3: TButton;
    Label2: TLabel;
    CheckBox2: TCheckBox;
    RadioGroup1: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

// *** Erstellt von einem Formular ein ScreenShot ***
function FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
var
  Rec: TRect;
  iWidth, iHeight, irechts, irunter: Integer;
  screenimage: tbitmap;
  jpgfile: tjpegimage;
begin
  screenimage := tbitmap.Create;
  with screenimage do try
    GetWindowRect(h, Rec);


    iWidth  := Rec.Right - Rec.Left;
    iHeight := Rec.Bottom - Rec.Top;

    irechts := 0;
    irunter := 0;
    Width := iWidth;
    Height := iHeight;
    if Checkbox2.checked then begin
      if RadioGroup1.Index = 2 then begin
         irechts := iWidth - 350;
         irunter := 115;
      end;
    end;


    BitBlt(Canvas.Handle, irechts, irunter, iWidth, iHeight, GetWindowDC(h), 0, 0, SRCCOPY);


    Result := True;


//    try SaveToFile(Filename) except Result := False end;
    jpgfile := TJPEGImage.Create;
      try
        jpgfile.Assign(screenimage);
        jpgfile.SaveToFile(Filename);
      finally
        jpgfile.Free;
      end;
  finally
    ReleaseDC(h, GetWindowDC(h));
    Free;
  end;
end;


Aufgerufen wird die Function ganz einfach über nen Button...

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...


Zuletzt bearbeitet von Andi1982 am Di 22.06.04 09:41, insgesamt 1-mal bearbeitet
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Di 22.06.04 09:40 
Ah ok, ich habs schon...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls, ExtCtrls, jpeg;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Button3: TButton;
    Label2: TLabel;
    CheckBox2: TCheckBox;
    RadioGroup1: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    function FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

// *** Erstellt von einem Formular ein ScreenShot ***
function TForm1.FormularSaveScreenShot(FileName: String; h : hWnd): Boolean;
var
  Rec: TRect;
  iWidth, iHeight, irechts, irunter: Integer;
  screenimage: tbitmap;
  jpgfile: tjpegimage;
begin
  screenimage := tbitmap.Create;
  with screenimage do try
    GetWindowRect(h, Rec);


    iWidth  := Rec.Right - Rec.Left;
    iHeight := Rec.Bottom - Rec.Top;

    irechts := 0;
    irunter := 0;
    Width := iWidth;
    Height := iHeight;
    if Checkbox2.checked then begin
      if RadioGroup1.ItemIndex = 2 then begin
         irechts := iWidth - 350;
         irunter := 115;
      end;
    end;


    BitBlt(Canvas.Handle, irechts, irunter, iWidth, iHeight, GetWindowDC(h), 0, 0, SRCCOPY);


    Result := True;


//    try SaveToFile(Filename) except Result := False end;
    jpgfile := TJPEGImage.Create;
      try
        jpgfile.Assign(screenimage);
        jpgfile.SaveToFile(Filename);
      finally
        jpgfile.Free;
      end;
  finally
    ReleaseDC(h, GetWindowDC(h));
    Free;
  end;
end;

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 22.06.04 10:01 
Hallo!

Du brauchst kein "erledigt" mehr hinter den Titel Deines Postings schreiben. Klicke einfach auf den grünen Haken in Deinem ersten Postingin und der Thread wird entsprechend markiert!

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 22.06.04 10:16 
Habe ich bereits vorhin vorgenommen gehabt. Habe nun auch das "Erledigt" aus dem Titel genommen.

Cu,
Udontknow