Einzelnen Beitrag anzeigen

AlexII

Registriert seit: 28. Apr 2008
1.717 Beiträge
 
FreePascal / Lazarus
 
#48

Re: Meine Drag'n'Drop-Funktion ergänzen

  Alt 2. Apr 2010, 14:23
Delphi-Quellcode:
procedure TForm1.WMDROPFILES(var Msg: TMessage);
var j, zaehler: Cardinal;
    Buffer, Extension: String;
    i: Integer;
    List : TStringList;
    List2: TStringList;
begin
  inherited;
  Buffer := '';
  zaehler := DragQueryFile(Msg.WParam, $FFFFFFFF, nil, 0);
  for j := 0 to zaehler - 1 do
    begin
      SetLength(Buffer, DragQueryFile(Msg.WParam, j, nil, 0) + 1);
      DragQueryFile(Msg.WParam, j, @Buffer[1], Length(Buffer));
      Extension := ExtractFileExt(Buffer);
    end;
  DragFinish(Msg.WParam);

//Laden
if AnsiSameText(Trim(ExtractFileExt(Buffer)), '.crp') or AnsiSameText(Trim(ExtractFileExt(Buffer)), '.ccr') then
begin
List:=TStringList.Create;
  try
    List.LoadFromFile(Buffer);

    if ListBox1.Count<>0 then
    begin
    if MessageDlg(_('Retain existing radio stations list?'), mtConfirmation, [mbYes, mbNo, mbCancel], 0) = mrNo then
    begin
    ListBox1.Clear;
    ListBox2.Clear;
    ListBox3.Clear;
    ListBox4.Clear;
    end;
    end;

    if AnsiSameText(Trim(ExtractFileExt(Buffer)), '.crp') then
    begin
    for i:=0 to List.Count-1 do
    begin
    List2:=Explode('<>', List[i]);
    ListBox1.Items.Insert(i, List2[1]);
    ListBox2.Items.Insert(i, List2[2]);
    ListBox3.Items.Insert(i, List2[3]);
    ListBox4.Items.Insert(i, List2[4]);
    List2.Free;
    end;
    end else
        begin
        for i:=0 to List.Count-1 do
        begin
        List2:=Explode('=', List[i]);
        ListBox1.Items.Insert(i, List2[1]);
        ListBox2.Items.Insert(i, List2[2]);
        ListBox3.Items.Insert(i, List2[3]);
        ListBox4.Items.Insert(i, List2[4]);
        List2.Free;
        end;
        end;

  finally
    List.Free;
  end;
end;
end;
Bin Hobbyprogrammierer! Meine Fragen beziehen sich meistens auf Lazarus!
  Mit Zitat antworten Zitat