Autor Beitrag
Hyperia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 13:56 
Hi

ich bin grad dabei delphi zu lernen
und jetzt steh ich wieder mal vor einem Problem und zwar


ich schreibe gerade einen "Screen SHot Maker" :D
also hier erst mal die unit damit ihr vllt dürchblickt wie ichs geschrieben hab

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:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, JPEG, ShellApi, Menus, ComCtrls;

type
  TForm1 = class(TForm)
    Button2: TButton;
    Button1: TButton;
    Button3: TButton;
    Button4: TButton;
    CheckBox1: TCheckBox;
    Button5: TButton;
    procedure FormCreate(Sender: TObject);



    procedure Button5Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;



implementation

{$R *.dfm}

Procedure BmpToJpg(const Filename: String; Quality: TJPEGQualityRange=100);
var
 Bmp: TBitmap;
 Jpg: TJpegImage;
begin
Bmp:=TBitmap.Create;
Jpg:=TJpegImage.Create;
try
  Bmp.LoadFromFile(Filename);
  Jpg.CompressionQuality:=Quality;
  Jpg.Assign(Bmp);
  Jpg.SaveToFile(ChangeFileExt(Filename, '.jpg' ));
finally
  Jpg.Free;
  Bmp.Free;
end;
end;

procedure SaveAppScreen(const SaveBmpFileName: string);
var
  Bitmap: TBitmap;
  Canvas: TCanvas;
begin
  Canvas := TCanvas.Create;
  try
    Canvas.Handle := GetWindowDC(0);
    try
      Bitmap := TBitmap.Create;
      try
        Bitmap.Width := Application.MainForm.Width;
        Bitmap.Height:= Application.MainForm.Height; 
        Bitmap.PixelFormat := pfDevice;
        BitBlt(Bitmap.Canvas.Handle, 0, 0, Pred(Application.MainForm.Width), Pred(
               Application.MainForm.Height), Canvas.Handle,
               Application.MainForm.Left, Application.MainForm.Top,
               Bitmap.Canvas.CopyMode);
        Bitmap.SaveToFile(SaveBmpFileName);
      finally 
        FreeAndNil(Bitmap);
      end;
    finally 
      ReleaseDC(0, Canvas.Handle);
    end;
  finally
    FreeAndNil(Canvas);
  end;
end;



procedure TForm1.Button2Click(Sender: TObject);
var
  zahl : integer;
  p : TFileName;

begin
Button2.Tag := Button2.Tag +1;



P:='C:\Screenie.bmp';

RenameFile('C:\Screenie.jpg', PCHAR('C:\Screenie'+IntToStr(Button2.Tag)+'.jpg'));
RenameFile('C:\Screenie.bmp', PCHAR('C:\Screenie'+IntToStr(Button2.Tag)+'.bmp'));
SaveAppScreen(p);
if CheckBox1.Checked then
begin
  BmpToJpg(p);
  deletefile(p);
end;


end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Form1.Width := 800;
Form1.Height := 600

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Form1.Width := 1024;
Form1.Height := 768
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Form1.Width := 1280;
Form1.Height := 1024;
end;



procedure TForm1.FormShow(Sender: TObject);
begin
Form1.ScreenSnap := true;
Form1.SnapBuffer := 30;
end;

procedure TForm1.Button5Click(Sender: TObject);
var
  p : TFileName;
  j : TFileName;

begin
 P:='C:\Screenie.bmp';
 j:='C:\Screenie.jpg';

  if ShellExecute(Application.Handle,
                 'open',
                 PChar(p),
                 Nil, Nil, SW_NORMAL) <= 32 then
    ShellExecute(Application.Handle,
                 'open',
                 PChar(j),
                 Nil, Nil, SW_NORMAL)


end;







procedure TForm1.FormCreate(Sender: TObject);
begin
Button2.Tag := 0;
end;

end.




jezz is mein problem :

- das die zahl bei Button2.Tag beim beenden in ein text oder so gespeichert wird
- und das ich iergendwie eine option einbau , wo die screens gespecihert werden




rapidshare.com/files...nShotMaker_v._1b.rar hier is nochmal die *.exe die unit und ne readme






Ich hoffe ihr versteht mich


Mfg HyP


Zuletzt bearbeitet von Hyperia am Sa 02.06.07 15:25, insgesamt 1-mal bearbeitet
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 02.06.07 14:05 
Also ganz ehrlich: ich weiß nicht wo dein Problem liegt? Außerdem kann ich die Datei nicht runterladen. Muss noch so circa 26 minuten warten. Vllt. hilft dir das

P.S.: Nimm mal bitte nicht so viele Leerzeichen und ändere den Titel so, dass man weiß, was du willst.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 02.06.07 14:05 
Gib mal deinem Thread einen vernünftigen Titel, damit man auch weiss was Du möchtest. :wink:
Das kam Mir doch irgendwie bekannt vor siehe
www.delphipraxis.net....html&highlight=

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 02.06.07 14:35 
Der Quelltext sollte mal ein wenig besser geordnet werden:
1. Einrückung gezielter verwenden
2. überflüssige Leerzeilen entfernen (wir programmieren hier kein BASIC, wo man 10 Zeilen platz mussen lass, um später noch was zu ergänzen) ...

Weiterhin hat das Forum eine Attachment-Funktion, um deine Dateien anzuhängen ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 15:26 
okay title hab ich geändert

andere hinweiße aufgenommen



aber meine probleme sind noch nicht gelöst ^^

- das die zahl bei Button2.Tag beim beenden in ein text oder so gespeichert wird
- und das ich iergendwie eine option einbau , wo die screens gespecihert werden
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 02.06.07 15:31 
Ok, dann wolln wir mal ;-)

Schau dir am besten mal TIniFile oder TMemIniFile an. Das sind Klassen, mit denen man sehr einfach z.B. Programmoptionen speichern kann. Zahlen gehen mit ini.WriteInteger(...), Strings mit ini.WriteString(...)

_________________
We are, we were and will not be.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 15:40 
okay


aber das was ich erst mal saven will is ja weder ne zahl noch ein string, oda?

wie kann das ausgelesen und gespeichert werden?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 02.06.07 15:49 
Der Tag eines Buttons ist ein Integer-Wert, und ein Dateipfad ein String...

_________________
We are, we were and will not be.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 02.06.07 15:52 

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 15:55 
okay ich versuchs erst mal mit der pdf hinzubekommen


wenn nicht meld ich mich nochmal ^^
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 16:05 
okay ich hab mein erstes Problem


gibts iergendwie in delphi den befehl

OnExit oder so


also das etwas passiern soll , wenn das programm geschlossen wird??
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 02.06.07 16:10 
Zum Speichern meinst du? Das kann man gut im OnClose des Hauptformulars machen ;-). Lesen ins OnShow, oder auch schon im Create.

_________________
We are, we were and will not be.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 02.06.07 16:10 
Neue Frage, neuer Thread. :wink: :!:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  ShowMessage('Form wird geschlossen');
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 02.06.07 16:13 
Solange es hier ums Speichern von Programm-Einstellungen geht, lassen wir das hier laufen ;-). Das in Einzel-Threads aufzudröseln wäre dann doch etwas viel des Guten...

_________________
We are, we were and will not be.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 16:18 
aus einem ungeklärtem grund bekomm ich

FormCloseQuery

unterstrichen

mit der bezeichnung "undefinerter Bezeichner"



was muss ich machen?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 02.06.07 16:24 
Doppelklick im OI bei OnCloseQuery der Form.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 18:28 
EDITED

das was hier vorher stand war schwachsinn

aber warum funktionierts net so??
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.FormCreate(Sender: TObject);
var
var1:Integer ;
begin


ini:= TiniFile.Create('C:\ini.ini');
if ini.SectionExists('asd') then  var1:= ini.ReadInteger('asd', 'Button2.Tag', 0) and var1:=Button2.Tag
else Button2.Tag := 0 ;


end;




procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
ini.WriteInteger('asd', 'Button2.tag', Button2.Tag);
end;

end.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 02.06.07 19:35 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Button2.Tag := 0;
  ini:= TiniFile.Create('C:\ini.ini') ;
  try
  Button2.Tag:=ini.ReadInteger('asd', 'Button2tag', 0);
  finally
  ini.free;
end;
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Sa 02.06.07 20:24 
THX!