AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi TWebBrowser : Alle Input Felder, Bilder etc. auflisten
Thema durchsuchen
Ansicht
Themen-Optionen

TWebBrowser : Alle Input Felder, Bilder etc. auflisten

Ein Thema von Assun · begonnen am 2. Aug 2005 · letzter Beitrag vom 7. Sep 2005
 
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#9

Re: TWebBrowser : Alle Input Felder, Bilder etc. auflisten

  Alt 4. Aug 2005, 16:59
Folgender Code benötigt noch ein Treeview auf dem Formular:
Delphi-Quellcode:
procedure TFrmHTMLUpload.FillTreeView(WebBrowser: TWebBrowser);
var
  i,j, k :Integer;
  FormItem, Element, SubElement: OleVariant;
  root : TTreeNodes;
  child, child2, child3 : TTreeNode;
  s_type : string;

begin
   root := TreeView1.Items;
   root.Clear;

  //count forms on document
  for I:=0 to WebBrowser.OleObject.Document.forms.Length -1 do
  begin
    FormItem := WebBrowser.OleObject.Document.forms.Item(I);

    if VariantIsObject(FormItem.Name) then
       child := root.AddChild(nil, 'Form'+IntToStr(i)+': '+FormItem.Name.Name)
    else
       child := root.AddChild(nil, 'Form'+IntToStr(i)+': '+FormItem.Name);
    child.ImageIndex := 3;


    For j:= 0 to FormItem.Length-1 do
    begin
      try
         Element := FormItem.Item(j);
         //when the fieldname is found, try to fill out
         child2 := root.AddChild(child, Element.Name+' = '+Element.Value);

         s_type := Element.Type;

         if s_type = 'submitthen
            child2.ImageIndex := 1
         else if s_type = 'textthen
            child2.ImageIndex := 0
         else if s_type = 'filethen
            child2.ImageIndex := 2
         else if s_type = 'hiddenthen
            child2.ImageIndex := 4
         else if s_type = 'checkboxthen
            child2.ImageIndex := 5
         else if s_type = 'radiothen
            child2.ImageIndex := 6
         else if s_type = 'select-onethen
            child2.ImageIndex := 7
         else
            child2.ImageIndex := -1;

         child3 := root.AddChild(child2, s_type);
         child3.ImageIndex := -1;


         if s_type = 'textthen
         begin
            child3 := root.AddChild(child2, 'MaxLen='+IntToStr(Element.maxLength));
            child3.ImageIndex := -1;
         end
         else if s_type = 'select-onethen
         begin
            for k := 0 to Element.Options.Length-1 do
            begin
               SubElement := Element.Options.Item(k);
               child3 := root.AddChild(child2, SubElement.Text+ ' = <'+SubElement.Value+'>');
               child3.ImageIndex := -1;

            end;

// ShowMessage(IntToStr(Element.Options.Length));
         end;

         if (s_type = 'hidden') then
         else
            ListBox1.Items.Add(Element.Name);

      except
        on E:Exception do
         root.AddChild(child, E.Message);
      end;
    end;
  end;

   if root.Count > 0 then
      root.GetFirstNode.Expand(True);
end;
Andreas
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz