Autor Beitrag
Qwert Zuiop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Win XP
Delphi 7 Pers. (Englisch)
BeitragVerfasst: Mi 06.09.06 20:58 
Hi,
ich habe hier im Forum einige Zeit nach einer Anleitung gesucht, wie man ein Bild per drag&drop öffnen kann, hab aber keine Anweisungen gefunden. Das Ziel soll sein, dass man eine Bilddatei zB. aus dem Windowsexplorer in das Porgramm auf ein Image zieht und es beim loslassen der Maus öffnet. Es kann gut sein, dass die Antwort ziemlich simpel ist, aber ich habe davon leider überhaut keine Ahnung. Aus diesem Grund bitte ich auch um eine anfängergerechte Erklärung.

Vielen Dank schon mal im Vorraus

Qwert
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: Mi 06.09.06 21:12 
So gehts - Unit ShellApi nicht vergessen. Wenn man JPEG auch mit einbindet, klappts auch mit jpgs :D
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:
23:
24:
25:
26:
27:
28:
TForm1 = class(TForm)
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    Procedure WMDropFiles (Var aMsg: tMessage);  message WM_DROPFILES;
  end;
//...
procedure TForm1.FormCreate(Sender: TObject);
begin
  DragAcceptFiles (Handle, True);
end;

Procedure TForm1.WMDropFiles (Var aMsg: tMessage);
var size, FileCount: integer;
  filename: Pchar;
begin
  FileCount := DragQueryFile (aMsg.WParam, $FFFFFFFF, nil, 255);
  if FileCount > 0 then
  begin
      Size := DragQueryFile (aMsg.WParam, 0, nil, 0) + 1;
      Filename := StrAlloc (Size);
      If DragQueryFile (aMsg.WParam, 0, Filename, Size) = 1 Then
      // nix
      else
        image1.Picture.LoadFromFile(Filename);
  end;
end;

_________________
We are, we were and will not be.
Qwert Zuiop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Win XP
Delphi 7 Pers. (Englisch)
BeitragVerfasst: Di 12.09.06 21:16 
Hey, thx schonmal,
noch eine Frage: was ist mit

Zitat:
Unit ShellApi nicht vergessen


gemeint?

Qwert Zuiop
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: Mi 13.09.06 09:08 
Damit ist gemeint, dass man die Unit ShellApi unter "Uses" mit eintragen muss. Sonst meckert der Compiler "undefinierter Bezeichner" oder ähnliches an der einen oder anderen Stelle.

_________________
We are, we were and will not be.
Qwert Zuiop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16

Win XP
Delphi 7 Pers. (Englisch)
BeitragVerfasst: Sa 23.09.06 20:20 
Vielen Dank für die ausführliche Erklärung