Anders Melander har en komponent suite der hedder noget med drag og drop ... Kig på han side http://www.melander.dk/delphi/dragdrop/#Download der finder du et eksemple der kan det du efter spørger.
Jeg her downloadet den der D&D ting fra anders med det er noget lort.. Den kan heller ikke det jeg gerne vil have den til, jeg skal ikke kopiere en fil, men lave en fil ud fra en Buffer.
Jeg vil helst være fri for treideparts komponenter... men hvis du har lyst så ok.. men der må da være en nem måde... det var da meget næmt at får det til at virke så at man kunne trække filer ind...
Der er IKKE en nem måde .. COM interfacet til din Explore ER meget grimt ..... Det har Anders formået at pakke pænet ind ... Filer TIL og FRA din Application har INTET med hinanden at gøre ...
function PCharToStr(S:Pointer):string; var i:integer; St:string; begin St := \'\'; i := 0; while( Byte(S^) <> 0) and (i < 256) do begin St := St + char(S^); s := Pointer( Longint(S)+1); end; result := St; end;
function StrToPChar(s:string):Pointer; var Buffer:pointer; i:integer; l:longint; begin GetMem(Buffer,Length(s)+1); l := longint(Buffer); for i := 1 to Length(s) do begin char(Pointer(l)^) := s[i]; Inc(l); end; byte(Pointer(l)^) := 0; result := Buffer; end; {$R *.DFM}
procedure TMainForm.UpdateList; var Count:longint; i:longint; Name:PChar; Size:longint; ID:longint; Item:TListItem; s:string; begin ListView.Items.Clear; if ZDBCountItems(DB,@Count) = 0 then begin for i := 1 to Count do begin ZDBGetID(DB,i-1,@ID); ZDBGetItemInfo(DB,ID,@Name,@Size); Item := ListView.Items.Add; Item.Caption := Name;
if (Size < 1024) then Item.SubItems.Add(IntToStr(Size)+\' B\') else if (Size < 1024*1024) then begin s := IntToStr(Round( Size / (1024/10)) ); SetLength(s,Length(s)+1); s[Length(s)] := s[Length(s)-1]; s[Length(s)-1] := \'.\'; Item.SubItems.Add(s+\' KB\'); end else begin s := IntToStr(Round(Size / (1024*1024/10))); SetLength(s,Length(s)+1); s[Length(s)] := s[Length(s)-1]; s[Length(s)-1] := \'.\'; Item.SubItems.Add(s+\' MB\'); end;
procedure TMainForm.CreateArchive1Click(Sender: TObject); var TempDB:Pointer; OK:Bool; s:string; s2:string; begin PasswordForm.Edit1.Text := \'\'; if SaveArcDialog.Execute then if PasswordForm.ShowModal = mrOK then OK := true; if ConfigForm.Pref.ComfirmPasswordOnCreate then begin s2 := PasswordForm.Edit1.Text; PasswordForm.Edit1.Text := \'\'; s := PasswordForm.Label1.Caption; PasswordForm.Label1.Caption := \'Comfirm password:\'; ok := PasswordForm.ShowModal = mrOK; if ok then if PasswordForm.Edit1.Text <> s2 then ok := false; PasswordForm.Label1.Caption := s; end; if not ok then ShowMessage(\'Password not comfirmed\') else begin if ZDBCreate(StrToPChar(SaveArcDialog.FileName),@TempDB,StrToPChar(PasswordForm.Edit1.Text)) <> 0 then ShowMessage(\'Unabel to Create Archive\') else begin ZDBClose(DB); DB := TempDB; Caption := ExtractFileName(SaveArcDialog.FileName)+\' - Zioncrypt\'; MainMenu1.Items.Items[1].Enabled := true; UpdateList; end; end; end;
procedure TMainForm.Open1Click(Sender: TObject); var TempDB:Pointer; begin if OpenArcDialog.Execute then if PasswordForm.ShowModal = mrOk then if ZDBOpen(StrToPChar(OpenArcDialog.FileName),@TempDB,StrToPChar(PasswordForm.Edit1.Text)) <> 0 then ShowMessage(\'Unabel to open Archive\') else begin ZDBClose(DB); DB := TempDB; Caption := ExtractFileName(OpenArcDialog.FileName)+\' - Zioncrypt\'; MainMenu1.Items.Items[1].Enabled := true; UpdateList; end; end;
procedure TMainForm.FormCreate(Sender: TObject); begin DB := nil;
procedure TMainForm.ExtractFile1Click(Sender: TObject); begin ProssessForm.ExtractFiles(DB); end;
procedure TMainForm.MoveFile1Click(Sender: TObject); begin ProssessForm.AddFiles(DB,true); UpdateList; end;
procedure TMainForm.Delete1Click(Sender: TObject); begin if (not ConfigForm.Pref.ConfirmDelete) or (ComfirmDeleteForm.ShowModal = mrYes) then begin ProssessForm.DeleteFiles(DB); UpdateList; end; end;
procedure TMainForm.PopupMenu1Popup(Sender: TObject); begin PopupMenu1.Items.Items[0].Enabled := false; PopupMenu1.Items.Items[1].Enabled := false; PopupMenu1.Items.Items[2].Enabled := false; PopupMenu1.Items.Items[3].Enabled := false; if DB <> nil then begin PopupMenu1.Items.Items[0].Enabled := true; PopupMenu1.Items.Items[1].Enabled := true; end; if ListView.SelCount > 0 then begin PopupMenu1.Items.Items[2].Enabled := true; PopupMenu1.Items.Items[3].Enabled := true; end; end;
procedure TMainForm.SelectAll1Click(Sender: TObject); var i:longint; begin for i := 1 to ListView.Items.Count do ListView.Items.Item[i-1].Selected := true; end;
procedure TMainForm.Preferenses1Click(Sender: TObject); begin ConfigForm.CheckBox1.Checked := ConfigForm.Pref.ComfirmPasswordOnCreate; ConfigForm.CheckBox2.Checked := ConfigForm.Pref.ConfirmDelete; if ConfigForm.ShowModal = mrOK then begin ConfigForm.Pref.ComfirmPasswordOnCreate := ConfigForm.CheckBox1.Checked; ConfigForm.Pref.ConfirmDelete := ConfigForm.CheckBox2.Checked; ConfigForm.SavePref; end; end;
procedure TMainForm.About1Click(Sender: TObject); begin AboutForm.ShowModal; end;
procedure TMainForm.DropFiles(var DropFileMsg: TwmDropFiles); var i, dropcount : integer; filename : array[0..500] of char; s:string; begin if (DB = nil)then begin end else begin dropcount := dragqueryfile(DropFileMsg.drop,$ffffffff,nil,0); ProssessForm.OpenDialog1.Files.Clear; for i := 0 to dropcount-1 do begin dragqueryfile(DropFileMsg.drop,i,filename,500); ProssessForm.OpenDialog1.Files.Add( string(filename) ); end; dragfinish(DropFileMsg.drop); Application.BringToFront; ProssessForm.AddFilesDrop(DB,false); UpdateList; end; end;
OKEffect := DROPEFFECT_NONE; if (CheckBoxCopy.Checked) then OKEffect := OKEffect OR DROPEFFECT_COPY; if (CheckBoxMove.Checked) then OKEffect := OKEffect OR DROPEFFECT_MOVE; if (CheckBoxLink.Checked) then OKEffect := OKEffect OR DROPEFFECT_LINK; }
Result := DoDragDrop(DropSource as IDataObject, DropSource as IDropSource, OKEffect, Effect);
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.