Thema: Delphi Datei Icons in Delphi

Einzelnen Beitrag anzeigen

Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#7

Re: Datei Icons in Delphi

  Alt 19. Jul 2007, 17:19
Delphi-Quellcode:
procedure TfrmMain.DispDir;
var
  root,tmp: IXMLNode;
  ListItem: TListItem;
  i:integer;
  fSize : string;
  function FileImgIndex(FileName: String):integer;
  var
    Ext:String;
  begin
    Result := 2;
    Ext:= LowerCase(ExtractFileExt(FileName));
    if Ext='.3gpthen Result := 3 else
      if Ext='.bmpthen Result := 4 else
      if Ext='.bmxthen Result := 5 else
      if Ext='.cssthen Result := 6 else
      if Ext='.hfithen Result := 7 else
      if Ext='.gifthen Result := 8 else
      if Ext='.htmlthen Result := 9 else
      if Ext='.imythen Result := 10 else
      if Ext='.jpgthen Result := 11 else
      if Ext='.midthen Result := 12 else
      if Ext='.mmcthen Result := 13 else
      if Ext='.mmfthen Result := 14 else
      if Ext='.mp3then Result := 15 else
      if Ext='.mp4then Result := 16 else
      if Ext='.pngthen Result := 17 else
      if Ext='.srtthen Result := 18 else
      if Ext='.svgthen Result := 19 else
      if Ext='.tiffthen Result := 20 else
      if Ext='.vmgthen Result := 21 else
      if Ext='.wavthen Result := 22 else
      if Ext='.wbmpthen Result := 23 else
      if Ext='.xhtmlthen Result := 24 else
                  if Ext='.xlsthen Result := 25 else
       if Ext='.derthen Result := 26 else
      if Ext='.docthen Result := 27 else
      if Ext='.datthen Result := 28 else
      if Ext='.jarthen Result := 29 else
      if Ext='.pdfthen Result := 30 else
      if Ext='.txtthen Result := 31 else
      if Ext='.jadthen Result := 32;
  end;
 function FrmTimeStr(t:string):string;
  begin
    Result := Copy(t,1,4)+'-'+Copy(t,5,2)+'-'+Copy(t,6,2)+' '+
              Copy(t,10,2)+':'+Copy(t,12,2)+':'+Copy(t,14,2);
  end;
begin
// XML.XML.Text := Obex_Dir;
  XML.XML.Text := HTMLContent (Obex_Dir);
  ListView.Items.Clear;
  with ListView.Items.Add do
  begin
    ImageIndex := 0;
    Caption := '..';
    SubItems.Add(' <DIR>');
    SubItems.Add(''); //
    SubItems.Add('');
  end;

  XML.Active := true;
  root := XML.DocumentElement;
  for i:=0 to root.ChildNodes.Count-1 do
  begin
    tmp:=root.ChildNodes.Nodes[i];
    ListItem := ListView.Items.Add;
    ListItem.Caption := tmp.Attributes['name'];
    if tmp.NodeName ='folderthen
    begin
      ListItem.ImageIndex := 1;
      ListItem.SubItems.Add(' <DIR>');
      ListItem.SubItems.Add('');
    end;
    if tmp.NodeName ='filethen
    begin
      ListItem.ImageIndex := FileImgIndex(ListItem.Caption);
      fSize := tmp.Attributes['size'];
      fSize := StringOfChar(' ',7-Length(fSize))+fSize;
      ListItem.SubItems.Add(fSize);
      ListItem.SubItems.Add(ExtractFileExt(ListItem.Caption)+' Datei');
    end;
    ListItem.SubItems.Add(FrmTimeStr(tmp.Attributes['modified']));
  end;
  XML.Active := false;
  Label2.Caption :=ProductID;
    Label1.Caption := ProductID +':/';
      for I := 0 to PathList.Count - 1 do // Iterate
            begin
        Label1.Caption := Label1.Caption + '/'+ PathList.Strings[I];
end;
end;
Musst du dir halt für deine Bedürfnisse umstellen
Angehängte Grafiken
Dateityp: bmp imagelist_icons_199.bmp (36,1 KB, 28x aufgerufen)
Marcel
  Mit Zitat antworten Zitat