Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 22.12.05 19:37 
Hi Delpher,

wie kann ich OHNE showmessage() zum nächsten Bild weiterschalten lassen?

Code:
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:
unit BsSch;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, JPEG, ImgList, StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Image1: TImage;
    FileListBox1: TFileListBox;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  neustart     : boolean;
  bild         : TJPEGImage;
  KeyboardHook : HHOOK;
  MouseHook    : HHOOK;
  bildnr       : integer = 0;

implementation

{$R *.dfm}


function KeyboardProc(nCode:integer; wParam:longint; lParam:longint):longint; stdcall;
begin
  result := CallNextHookEx(KeyboardHook, ncode, wparam, lparam);
  form1.timer1.enabled := false;  form1.timer1.enabled := true;
end;

function MouseProc(nCode:integer; wparam: longint; var MouseHookStruct: TMouseHookStruct):longint; stdcall;
begin
  result := CallNextHookEx(MouseHook, nCode, wparam, longint(@MouseHookStruct));
  form1.timer1.enabled := false;  form1.timer1.enabled := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if neustart = false then
  begin
    neustart := true;
    bild := TJPEGImage.create; Image1.Visible := true;
    repeat
      inc(bildnr);
      bild := TJPEGImage.create; Image1.Visible := true;
      bild.loadfromfile(filelistbox1.directory + '\' + filelistbox1.Items[bildnr]);
      image1.Picture.Graphic := bild;
      showmessage('weiter ...');
    until bildnr = filelistbox1.items.count-1;
    image1.Visible := false;
    neustart := false;
    HALT;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);        // Initialisierungen
begin
  windowstate := wsmaximized; //BorderIcons := BorderIcons - [biSystemMenu];
  filelistbox1.Directory := 'C:\bilder\';
  timer1.Enabled := false;
    KeyboardHook := SetWindowsHookEx(WH_KEYBOARD, @KeyboardProc, 0, GetCurrentThreadID);
    MouseHook    := SetWindowsHookEx(WH_MOUSE, @MouseProc, 0, GetCurrentThreadID);
    timer1.interval := 1*1000;     //15*60000;  // nach 15 Minuten
  timer1.enabled := true;
end;


end.


Nach ca. 2 Sekunden soll das nächste Bild erscheinen.

Danke für Hilfe,
Detlef A.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 22.12.05 19:49 
System -> TTimer dort 2000 als interval, fertig ;)

achso, wie ich sehe hast du das schon, aber was soll die schleife ?
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 22.12.05 19:52 
Verschieb das Zeug aus Deiner repeat-Schleife raus in die Timer-Prozedur. Diese Prozedur wird alle [Timer.Intervall] ms aufgerufen, Du brauchst also keine Schleife.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 22.12.05 20:17 
Danke bisher, aber das war's noch nicht - denn wenn ich die showmessage rausnehme, kommt gar kein Bild und wenn ich die repeat-schleife rausnehme, kommt nur ein Bild.

Gruß, Detlef
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 22.12.05 20:39 
Wozu hast Du eigentlich die Hooks und wieso machst Du das:
 form1.timer1.enabled := false;  form1.timer1.enabled := true; :?:
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Do 22.12.05 22:41 
Hi,

du hast mal wieder völlig recht, Uwe!

Mittlerweile habe ich den Code völlig überarbeitet und es läuft - ohne showmessage, ohne HOOK, ohne enabled und was so überflüssig war!

Wird der jetzige 50-Zeilen-Code gewünscht?

Gruß,
Detlef A.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 22.12.05 23:33 
user profile iconD. Annies hat folgendes geschrieben:
Hi,

du hast mal wieder völlig recht, Uwe!

Mittlerweile habe ich den Code völlig überarbeitet und es läuft - ohne showmessage, ohne HOOK, ohne enabled und was so überflüssig war!

Wird der jetzige 50-Zeilen-Code gewünscht?

Gruß,
Detlef A.

Jo, reich ma rüber ;-)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 23.12.05 09:09 
Moin, UWE,
hier ist der Code:

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:
unit BsSch;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, JPEG, ImgList, StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Image1: TImage;
    FileListBox1: TFileListBox;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1  : TForm1;
  bild   : TJPEGImage;
  bildnr : integer = -1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  bild := TJPEGImage.create;
  Image1.Visible := true;
  inc(bildnr);
  if bildnr < filelistbox1.items.count-1 then
  begin
    bild.loadfromfile(filelistbox1.directory + '\' + filelistbox1.Items[bildnr]);
    image1.Picture.Graphic := bild;
  end
  else HALT;  //ABORT;  //EXIT;
end;

procedure TForm1.FormCreate(Sender: TObject);        // Initialisierungen
begin
  windowstate := wsmaximized; //BorderIcons := BorderIcons - [biSystemMenu];
  filelistbox1.Directory := 'C:\bilder\';
  timer1.interval := 1*2000; 
end;

end.


P.S. Gibt es noch die Möglichkeit, auf die Größe des Bildes zu reagieren?
Sonst gibt es ja Verzerreffekte, wenn man auf stretch = true einstellt.

Bis dann erstmal,
Detlef A.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Fr 23.12.05 18:39 
Hi,
ich hab Dir mal aus Zeitgründen eines meiner gaaaanz alten Projekte angehängt, wo ich eigentlich genau das gemacht habe, was Du willst. Das Bild wird auf die zur Verfügung stehende Größe verkleinert, je nachdem ob es zu hoch oder zu breit ist.

Hat noch jede Menge Bugs, aber die Grundidee und ein paar Przeduren Prozeduren könnten Dir vielleicht helfen ;-)
Einloggen, um Attachments anzusehen!
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Fr 23.12.05 20:35 
Hi, Uwe,
was für eine Freude - und das einmal über den Teich!

Jetzt werde ich damit erst einmal schön spielen ...
(Ein Spinedit habe ich auch noch nie verwendet)

Bis dann,
Detlef

P.S. Ich lass den Thread noch offen, andere sind ja auch ganz gut am Saugen...