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



BeitragVerfasst: Di 29.05.07 20:18 
Hi ich Bräuchte mal kurze hilfe


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button2Click(Sender: TObject);
var
  zahl : integer;
  p : TFileName;

begin
zahl:= 1;
P:='C:\Screenie.bmp';

RenameFile('C:\Screenie.bmp''C:\Screenie2.bmp')  ;


in die zeile soll bei Screenie2 als 2 ne Variable eingebaut werden die sich bei jedem klick um eins erhöht


wie bekomm ich das hin?

bitte um antwort

Euer Nobby Hyp

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:24 
Moin und :welcome: im Forum!

user profile iconHyperia hat folgendes geschrieben:
in die zeile soll bei Screenie2 als 2 ne Variable eingebaut werden die sich bei jedem klick um eins erhöht

Lösungsidee: :idea:

- im FormCreate() setzt du Button2.Tag := 0; (Zähler initialisieren)
- in der OnClick-Methode für Button2 machst du als erstes: Button2.Tag := Button2.Tag +1; damit der Zähler beim Klicken weiter läuft.
- Und dann baust du testweise diese Zeile in den OnClick-Handler: ShowMessage(IntToStr(Button2.Tag)+' mal geklickt!'); ein

Den "Rest" kannst du dann auch sicher alleine zusammenbauen. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 20:27 
ähmm das versteh ich soweit , aber wies weiter geht kann ich mir leider auch noch nicht denken

habe heut angefangen mit delphi , also steh noch am absoluten anfang ^^



edit :: ich kann ja mal den quelltext posten damit du siehst wa sich vorhab
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:30 
Moin!

user profile iconHyperia hat folgendes geschrieben:
ähmm das versteh ich soweit

Gut, dann zeig mal deinen Code, der das, was ich vorgeschlagen habe, umsetzt; dann sehen wir weiter. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 20:31 
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:
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 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, 00, 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
zahl:= 1;
P:='C:\Screenie.bmp';

RenameFile('C:\Screenie.bmp''C:\Screenie2.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),
                 NilNil, SW_NORMAL) <= 32 then
    ShellExecute(Application.Handle,
                 'open',
                 PChar(j),
                 NilNil, SW_NORMAL)


end;

end.


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:33 
Was soll ich damit? :nixweiss:

user profile iconNarses hat folgendes geschrieben:
Gut, dann zeig mal deinen Code, der das, was ich vorgeschlagen habe, umsetzt; dann sehen wir weiter.

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 20:36 
achso sry,

ich weiß leider nicht wo ich FormCreate finde
oder wo ich das erstelle
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:38 
Moin!

user profile iconHyperia hat folgendes geschrieben:
ich weiß leider nicht wo ich FormCreate finde
oder wo ich das erstelle

Mach einen Doppelklich auf dem Formularhintergrund. ;)

Mir reicht übrigens der Button2-Handler, der restliche Code dürfte ja wohl eher uninteressant sein. :?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 20:44 
:D soweit klappt alles

also Button 2 handler ??


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Button2Click(Sender: TObject);
var
  zahl : integer;
  p : TFileName;

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

ShowMessage(IntToStr(Button2.Tag)+' mal geklickt!');

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

RenameFile('C:\Screenie.bmp''C:\Screenie2.bmp')  ;
SaveAppScreen(p);
if CheckBox1.Checked then
begin
  BmpToJpg(p);
  deletefile(p);



Und FormCreate


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormCreate(Sender: TObject);
begin
Button2.Tag := 0;
end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:50 
Moin!

user profile iconHyperia hat folgendes geschrieben:
:D soweit klappt alles

Fein. ;)

ausblenden Delphi-Quelltext
1:
2:
3:
ShowMessage(IntToStr(Button2.Tag)+' mal geklickt!');

RenameFile('C:\Screenie.bmp''C:\Screenie2.bmp');

Dann kann es ja jetzt nicht mehr soo schwer sein... :P

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 20:53 
DOCH

das klappt einfach iwi net


wenn ich das mach sieht das so aus

RenameFile('C:\Screenie.bmp', 'C:\Screenie(IntToStr(Button2.Tag)+'.bmp')') ;

aber das lässt sich dann net compilen
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 20:58 
Moin!

Bitte schließe deinen Delphi-Code auch in entsprechenden Tags ein, damit das Syntax-Highlighting aktiv wird (einfach den Quelltext markieren und auf das "+" neben "Delphi" oben im Editor klicken), danke!

Jetzt zu deinem Problem: Eine Textkonstante wird in Delphi (also in Pascal) mit einem Hochkomma eingeleitet und abgeschlossen. Jetzt prüfen wir diese Regel mal an deinem Quelltext: :?
ausblenden Delphi-Quelltext
1:
RenameFile('C:\Screenie.bmp''C:\Screenie(IntToStr(Button2.Tag)+'.bmp')');					

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 21:12 
sry aber ich weiß net was ne Textkonsonate ist :(
das is der teil , wo bis jezz alle versuche bei mir gescheitert sind
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Di 29.05.07 21:37 
ausblenden Delphi-Quelltext
1:
RenameFile('C:\Screenie.bmp', PCHAR('C:\Screenie'+IntToStr(Button2.Tag)+'.bmp'));					
Hyperia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Di 29.05.07 21:52 
DANKE


ihr habt mir sehr weiter geholfe

und jezz muss ich net nochmal fragen^^

MfG HyP
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 22:21 
Moin!

user profile icon-=LordEvil=- hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
RenameFile('C:\Screenie.bmp''C:\Screenie'+IntToStr(Button2.Tag)+'.bmp');					

Das PChar() ist nicht notwendig (genau genommen: überflüssig!), der Parameter ist als (Ansi-)String deklariert. :?

Warum du allerdings den Fragesteller die geradezu hirnzermarternde Aufgabe 'C:\Screenie'+ vor das IntToStr() zu setzen nicht selbst hast lösen lassen, ist mir noch nicht ganz klar... :| (wo doch der Code klar c&p-"Programmierung" ahnen lässt... :( )

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Di 29.05.07 22:41 
user profile iconNarses hat folgendes geschrieben:
Moin!

user profile icon-=LordEvil=- hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
RenameFile('C:\Screenie.bmp''C:\Screenie'+IntToStr(Button2.Tag)+'.bmp');					

Das PChar() ist nicht notwendig (genau genommen: überflüssig!), der Parameter ist als (Ansi-)String deklariert. :?

Warum du allerdings den Fragesteller die geradezu hirnzermarternde Aufgabe 'C:\Screenie'+ vor das IntToStr() zu setzen nicht selbst hast lösen lassen, ist mir noch nicht ganz klar... :| (wo doch der Code klar c&p-"Programmierung" ahnen lässt... :( )

cu
Narses


Pchar?:
jo stimmt, Irrtum.

c&p?:
Ich bin nicht so der c&p-Feind, ob er nun danach sucht, es lernt, oder ich ihm die Lösung poste und er sie studiert und lernt! Außerdem, wenn er sucht wird er es auch nur übernehmen... aus einer anderen Quelle halt... im Prinzip nix anderesl, nur Zeitaufwändiger.
Und verstehen wird er die Syntax jawohl!

mfg
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 29.05.07 23:31 
Moin!

user profile icon-=LordEvil=- hat folgendes geschrieben:
c&p?:
Ich bin nicht so der c&p-Feind, ob er nun danach sucht, es lernt, oder ich ihm die Lösung poste und er sie studiert und lernt!

Hach, diese brilliante Kombinationsgabe... :flehan: danke, dass du uns das Problem noch schnell gelöst hast, da wären wir ja im Leben nicht drauf gekommen... :roll:

user profile icon-=LordEvil=- hat folgendes geschrieben:
Außerdem, wenn er sucht wird er es auch nur übernehmen... aus einer anderen Quelle halt... im Prinzip nix anderesl, nur Zeitaufwändiger.
Selber suchen ist immer noch besser, als selber abschreibenunter der Lupe war die Verlockung "ich weiß es, ich weiß es" zu rufen, wohl doch größer, als die schwächlichen Ausreden jetzt noch kaschieren können, hm? :/

:|
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Nilan
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 29

Win VistaSP1

BeitragVerfasst: Mi 30.05.07 00:01 
Ich bin jemand, der sich eher nur die Beiträge durchliest, als selber zu posten.
Hier MUSS ich mich aber einfach einmischen, könnt ihr diese Diskussion, die durchaus häufig hier zu finden ist nicht wo anders durchführen? Obwohl ich sagen muss, dass ich vollkommen Narses zustimme, da ich selber immer versuche, etwas zu verstehen, bevor ich es auch übernehem.

Naja, ich wollte euch nicht persönlich angreifen oder so, also nehmts bitte nicht schlecht auf :wink:

Nilan :)


Zuletzt bearbeitet von Nilan am Mi 30.05.07 01:04, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 30.05.07 00:20 
Moin!

user profile iconNilan hat folgendes geschrieben:
könnt ihr diese Diskussion, die durchaus häufig hier zu finden ist nicht wo anders durchführen?

Nein, denn wo die Hobelspäne fallen, muss auch mal gefegt werden, sonst kann man irgendwann nicht mehr durch die Werkstatt laufen... :| (auch wenn du grundsätzlich Recht hast, das ist OT - und deshalb mein letzter Beitrag hier im Thread)

user profile iconNilan hat folgendes geschrieben:
Obwohl ich sagen muss, dass ich vollkommen Narses zustimme, da ich selber immer versuche, etwas zu verstehen, bevor ich es auch übernehem.

So ist es; die Qualität dieses Forums wird nur dann gut sein, wenn die Hilfe, die man hier kriegt, nachhaltig ist. Einfache Lösungen "vorzusagen" und "code-without-comment" sind vielleicht die schnellere Variante (und die für´s Ego :P), aber sicher nicht die Bessere! :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.