Thema Datum  Von Nutzer Rating
Antwort
03.02.2025 13:12:07 Gast98551
NotSolved
03.02.2025 19:04:25 Gast75772
NotSolved
03.02.2025 20:39:14 volti
NotSolved
04.02.2025 12:30:20 Gast19586
NotSolved
04.02.2025 14:08:15 Volti
NotSolved
04.02.2025 15:28:04 Gast67987
NotSolved
04.02.2025 15:58:49 Gast31143
NotSolved
04.02.2025 16:59:30 Gast39622
NotSolved
04.02.2025 18:12:20 volti
NotSolved
04.02.2025 18:25:46 volti
NotSolved
Rot Systree - Absturz bei Zugriff auf Knoten (externes Programm)
04.02.2025 19:13:41 volti
NotSolved
04.02.2025 22:38:12 Gast85035
NotSolved
04.02.2025 23:25:24 volti
NotSolved
05.02.2025 00:38:44 Gast32890
NotSolved
05.02.2025 08:42:33 volti
NotSolved
05.02.2025 08:56:36 volti
NotSolved
09.02.2025 21:57:35 Gast46537
NotSolved
05.02.2025 13:33:01 Gast89171
NotSolved
05.02.2025 15:04:45 Gast15904
NotSolved
09.02.2025 18:13:22 Gast6908
Solved

Ansicht des Beitrags:
Von:
volti
Datum:
04.02.2025 19:13:41
Views:
48
Rating: Antwort:
  Ja
Thema:
Systree - Absturz bei Zugriff auf Knoten (externes Programm)

Leider noch ein Update,

aber jetzt werden alle Root-Elemente abgerufen.....

Wichtige Info:

Es muss ByVal heißen, sondt kommt zwar kein Fehler aber auch kein weiteres Item.

hItem = SendMessageA(hTree, TVM_GETNEXTITEMTVGN_NEXTByVal hItem)

Code:
 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 
Option Explicit
Private Declare PtrSafe Function FindWindowA Lib "user32" ( _
        ByVal lpClassName As StringByVal lpWindowName As StringAs LongPtr
Private Declare PtrSafe Function FindWindowExA Lib "user32" ( _
        ByVal hWndParent As LongPtrByVal hWndChildAfter As LongPtr, _
        ByVal lpszClass As StringByVal lpszWindow As StringAs LongPtr
Private Declare PtrSafe Function SendMessageA Lib "user32" ( _
        ByVal hWnd As LongPtrByVal Msg As Long, _
        ByVal wParam As LongPtr, lParam As AnyAs LongPtr


' Konstanten für TreeView-Operationen
Const TV_FIRST     As Long = &H1100
Const TVM_GETCOUNT As Long = TV_FIRST + 5
Const TVM_GETNEXTITEM As Long = TV_FIRST + 10
Const TVM_GETITEM  As Long = TV_FIRST + 12
Const TVGN_ROOT    As Long = &H0
Const TVGN_CHILD   As Long = &H4
Const TVGN_NEXT    As Long = &H1

Type TVITEM
     mask           As Long
     hItem          As LongPtr
     STATE          As Long
     statemask      As Long
     pszText        As String
     cchTextMax     As Long
     iImage         As Long
     iSelectedImage As Long
     cChildren      As Long
     lParam         As LongPtr
End Type

Sub EnumerateTreeView()
  Dim hWnd   As LongPtr, hTree As LongPtr, hItem As LongPtr
  Dim TVI    As TVITEM
  Dim iZeile As Long, iAnz As Long, iAnzMax As Long

' Fenster "Diff" suchen
  hWnd = FindWindowA(vbNullString, "Diff")
  If hWnd = 0 Then
     MsgBox "Fenster mit Titel  ' Diff' nicht gefunden!", vbCritical, "TreeView""
     Exit Sub
  End If

' TreeView vorhanden?
  hTree = FindWindowExA(hWnd, 0, "SysTreeView32", vbNullString)
  If hTree = 0 Then
     MsgBox "Fenster enthält kein TreeView-Steuerelement!"
     Exit Sub
  End If

' Root-Knoten abrufen
  hItem = SendMessageA(hTree, TVM_GETNEXTITEMTVGN_ROOTByVal 0&)
  If hItem = 0 Then
     MsgBox "Kein Root-Knoten gefunden!", vbCritical, "TreeView"
     Exit Sub
  End If
  iAnzMax = CLng(SendMessageA(hTree, TVM_GETCOUNT0ByVal 0&))   ' Anzahl der Elemente

' Elemente durchgehen
  Do While hItem <> 0
     With TVI                                                      ' TVITEM initialisieren
         .mask = &H1   ' &H1 = TVIF_TEXT
         .hItem = hItem
         .pszText = String(256vbNullChar)                        ' Puffer initialisieren
         .cchTextMax = 256
         If SendMessageA(hTree, TVM_GETITEM0, TVI) <> 0 Then
            ' Knoteninformationen in die Tabelle schreiben
            Cells(iZeile + 15).Value = Left(.pszText, InStr(.pszText, vbNullChar) - 1)
            iZeile = iZeile + 1
         Else
            Debug.Print "Fehler beim Abrufen des Items: " & hItem
         End If
     End With
     ' Nächsten Knoten abrufen
     hItem = SendMessageA(hTree, TVM_GETNEXTITEMTVGN_NEXTByVal hItem)
  Loop

  MsgBox iZeile & " von" & Str(iAnzMax) & _
  " Elementen wurden in Spalte E eingefügt!", vbInformation, "TreeView"
End Sub
 
_________
viele Grüße
Karl-Heinz

Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
03.02.2025 13:12:07 Gast98551
NotSolved
03.02.2025 19:04:25 Gast75772
NotSolved
03.02.2025 20:39:14 volti
NotSolved
04.02.2025 12:30:20 Gast19586
NotSolved
04.02.2025 14:08:15 Volti
NotSolved
04.02.2025 15:28:04 Gast67987
NotSolved
04.02.2025 15:58:49 Gast31143
NotSolved
04.02.2025 16:59:30 Gast39622
NotSolved
04.02.2025 18:12:20 volti
NotSolved
04.02.2025 18:25:46 volti
NotSolved
Rot Systree - Absturz bei Zugriff auf Knoten (externes Programm)
04.02.2025 19:13:41 volti
NotSolved
04.02.2025 22:38:12 Gast85035
NotSolved
04.02.2025 23:25:24 volti
NotSolved
05.02.2025 00:38:44 Gast32890
NotSolved
05.02.2025 08:42:33 volti
NotSolved
05.02.2025 08:56:36 volti
NotSolved
09.02.2025 21:57:35 Gast46537
NotSolved
05.02.2025 13:33:01 Gast89171
NotSolved
05.02.2025 15:04:45 Gast15904
NotSolved
09.02.2025 18:13:22 Gast6908
Solved