Thema: Delphi AV bei TreeView-Click

Einzelnen Beitrag anzeigen

CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: AV bei TreeView-Click

  Alt 2. Dez 2003, 21:04
Hi Armin,
tut es aber leider nicht.

Folgender Source zum Schreiben der Daten in den TreeView:
Delphi-Quellcode:
procedure TfrmMain.UpdateTreeView;
var
  xmlLanguages, xmlCategories, xmlTipps: IXMLDOMNodeList;
  pNewLang, pNewCat, pNewTipp: PVirtualNode;
  pNewLngData, pNewCatData, pNewTippData: PTVData;
  i, j, k: integer;
  sXSL, sLngName, sCatName, sTippName: string;
begin
  vstData.Clear;
  vstData.BeginUpdate;

  sXSL := '/'+IDT_ROOTNODE+'/'+IDT_LANGNODE;
  xmlLanguages := xmlDoc.selectNodes(sXSL);
  for i:=0 to xmlLanguages.length-1 do begin
    pNewLang := vstData.AddChild(nil);
    pNewLngData := vstData.GetNodeData(pNewLang);
    pNewLngData^.dwSize := sizeof(PTVData);
    pNewLngData^.dwMode := 0;
    pNewLngData^.szHighlighter := xmlLanguages.item[i].attributes.getNamedItem(IDT_HIGHLIGHTERATTR).text;
    sLngName := xmlLanguages.item[i].attributes.getNamedItem(IDT_CAPTIONATTR).text;
    pNewLngData^.szName := sLngName;

    sXSL := '/'+IDT_ROOTNODE+'/'+IDT_LANGNODE+'[@'+IDT_CAPTIONATTR+'="'+sLngName+'"]'
                + '/'+IDT_TOPICNODE;
    xmlCategories := xmlDoc.selectNodes(sXSL);
    for j:=0 to xmlCategories.length-1 do begin
      pNewCat := vstData.AddChild(pNewLang);
      pNewCatData := vstData.GetNodeData(pNewCat);
      pNewCatData^.dwSize := sizeof(PTVData);
      pNewCatData^.dwMode := 1;
      sCatName := xmlCategories.item[j].attributes.getNamedItem(IDT_CAPTIONATTR).text;
      pNewCatData^.szName := sCatName;

      sXSL := '/'+IDT_ROOTNODE+'/'+IDT_LANGNODE+'[@'+IDT_CAPTIONATTR+'="'+sLngName+'"]'
                  + '/'+IDT_TOPICNODE + '[@'+IDT_CAPTIONATTR+'="'+sCatName+'"]'
                  + '/'+IDT_TIPPNODE;
      xmlTipps := xmlDoc.selectNodes(sXSL);
      for k:=0 to xmlTipps.length-1 do begin
        pNewTipp := vstData.AddChild(pNewCat);
        pNewTippData := vstData.GetNodeData(pNewTipp);
        pNewTippData^.dwSize := sizeof(PTVData);
        pNewTippData^.dwMode := 2;
        sTippName := xmlTipps.item[k].attributes.getNamedItem(IDT_CAPTIONATTR).text;
        pNewTippData^.szName := sTippName;
      end;
    end;
  end;

  vstData.EndUpdate;
  vstData.Refresh;
end;
Vielleicht ist da ja der Fehler.

Chris

[edit]Vielleicht noch die Typen:
Delphi-Quellcode:
  rTVData = packed record
    dwSize: DWORD; // size of record
    dwMode: DWORD; // 0: Language, 1: Category, 2: Tipp
    szName: WideString; // caption of node (name-attribute of xmlnode)
    szDescription: WideString; // description of Tipp (only mode 2)
    szSourcecode: WideString; // sourcecode of Tipp (only mode 2)
    szAuthor: WideString; // author of Tipp (only mode 2)
    szSource: WideString; // source of Tipp (only mode 2)
    szHighlighter: WideString; // highlighter of language (only mode 0)
  end;
  PTVData = ^rTVData;
[/edit]
  Mit Zitat antworten Zitat