unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
ShellAPI, Dialogs, ExtCtrls, StdCtrls, Menus, ExtDlgs, ComCtrls, TntExtCtrls;
type
TForm1 =
class(TForm)
PictureDialog: TOpenPictureDialog;
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Bildladen1: TMenuItem;
Beenden1: TMenuItem;
PictureList: TListView;
Memo: TMemo;
Image: TTntImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Bildladen1Click(Sender: TObject);
procedure Beenden1Click(Sender: TObject);
procedure MemoDragDrop(Sender, Source: TObject; X, Y: Integer);
protected
procedure WMDROPFILES (
var Msg: TMessage);
message WM_DROPFILES;
private
{ Private-Deklarationen }
FFileName:
String;
FFileList: TStrings;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Bildladen1Click(Sender: TObject);
var Picture: TBitmap;
begin
//Zusätzlich zum Verschieben mit Maus normales Laden per Dateidialog
if PictureDialog.Execute
then
begin
FFileName := PictureDialog.FileName;
{
Picture := TBitmap.Create;
Picture.LoadFromFile(FFileName);
}
Image.Picture.LoadFromFile(FFileName);
FFileList.AddObject(FFileName,Image);
Memo.Lines.Add(FFilename);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FFileList := TStringList.Create;
DragAcceptFiles(Form1.Handle, true);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FFileList.Free;
end;
procedure TForm1.MemoDragDrop(Sender, Source: TObject; X, Y: Integer);
var Msg: TMessage;
begin
{
Msg.WParamLo := X;
Msg.WParamHi := y;
WmDropFiles(Msg);
}
end;
procedure TForm1.WMDROPFILES(
var Msg: TMessage);
var
Picture : TBitmap;
size,i : integer;
Dateiname : PChar;
var
Img : TTntImage;
Item : TListItem;
begin
size := DragQueryFile(Msg.WParam, i ,
nil, 0) + 1;
Dateiname:= StrAlloc(size);
DragQueryFile(Msg.WParam,i , Dateiname, size);
//ShowMessage(StrPas(Dateiname));
//DragQueryFile übernimmt den Dateinamen
//Datei wird dann in Picture Objekt übernommen
//Picture := TBitmap.Create;
//Picture.LoadFromFile(StrPas(Dateiname));
Image.Picture.LoadFromFile(FFileName);
FFileList.AddObject(StrPas(Dateiname),Image);
Memo.Lines.Add(FFileList.Strings[FFileList.Count-1]);
Item := PictureList.Items.Add;
Item.Data := Image.Picture;
PictureList.Items.Item[PictureList.Items.Count-1].Data := Item.Data;
// Muss ich evtl noch Typumwandlungen vornehmen, wenn ja wie?
// oder wird das .jpg Format auch von TntImage einfach nicht unterstützt?
StrDispose(Dateiname);
DragFinish(Msg.WParam);
end;
end.