Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / March 2007



Tip: Looking for answers? Try searching our database.

'http://btmtz.mvps.org/vbexplorer/' help needed.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MAB - 28 Mar 2007 02:59 GMT
If this is the wrong group for this discussion, I apologize .  I 've tried to
contact Brad thru the email address given at MVPS.ORG but Brad hasn't
responded so far so I'm posting here in hopes to get relative quick help.

Brad has made an excellent Windows Explorer like VB6 app (Treeview &
Listview panes) using TreeView and ListView controls, Windows API calls and
sub-classing (using IShellFolder Extended Type Library v1.2).  I'm trying to
incorporate this functionality in to my application and I've got it working
however I need help with one thing that's crucial to my app.  

My app is saving (in registry) the path the user selected files from
(utilizing Brad's interface) for the purpose of using as a default the next
time the user launches the app.  Brad's code only populates a TreeView branch
as the user expands the tree (makes sense) but I need a branch to be
pre-populated at launch time so I can display to the user their previously
selected folder (default - branch expanded to).

Any help would be greatly appreciated!
Scott Seligman [MSFT] - 28 Mar 2007 03:38 GMT
>My app is saving (in registry) the path the user selected files from
>(utilizing Brad's interface) for the purpose of using as a default the next
>time the user launches the app.  Brad's code only populates a TreeView branch
>as the user expands the tree (makes sense) but I need a branch to be
>pre-populated at launch time so I can display to the user their previously
>selected folder (default - branch expanded to).

You need to pre-populate the entire treeview?  Can't you just expand
nodes of the treeview till you get to the node the user selected?

Signature

Scott Seligman [MSFT]
This posting is provided AS IS with no warranties, and confers
no rights.

MAB - 28 Mar 2007 16:14 GMT
Isn't that what I said?  In any case you are right, I need to pre-populate
only the branch up to the point where the user last selected.

How do I go about doing that?  I can store the complete path or the Node's
FullPath for later leverage.

> >My app is saving (in registry) the path the user selected files from
> >(utilizing Brad's interface) for the purpose of using as a default the next
[quoted text clipped - 5 lines]
> You need to pre-populate the entire treeview?  Can't you just expand
> nodes of the treeview till you get to the node the user selected?
Ken Halter - 28 Mar 2007 22:38 GMT
> Isn't that what I said?

Couldn't tell what you said <g>

> How do I go about doing that?  I can store the complete path or the Node's
> FullPath for later leverage.

fwiw, this works....
'====================
Private Sub Form_Activate()
  Static AlreadyBeenHere As Boolean
  If Not AlreadyBeenHere Then
     AlreadyBeenHere = True
     Call SelectNodes
  End If
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
  Dim oNode As Node
  Dim sPath As String
  Dim sDiv As String

  Set oNode = Node

  Do
     sPath = oNode.Text & sDiv & sPath
     sDiv = "|"
     Set oNode = oNode.Parent
  Loop While Not oNode.Parent Is Nothing

  'this stores the updated value each time a node is clicked.
  'change as required by your app
  Call SaveSetting("MyApp", "Settings", "CurrentNode", sPath)

End Sub

Private Sub SelectNodes()
  Dim sPath As String
  Dim sNodes() As String
  Dim lNode As Long
  Dim lLevel As Long
  Dim lCurrentNode As Long

  sPath = GetSetting("MyApp", "Settings", "CurrentNode", "")

  If Len(sPath) > 0 Then
     sNodes = Split(sPath, "|")
     lCurrentNode = 1

     For lLevel = 0 To UBound(sNodes)

        For lNode = lCurrentNode To TreeView1.Nodes.Count
           If TreeView1.Nodes(lNode).Text = sNodes(lLevel) Then
              TreeView1.Nodes(lNode).Selected = True
              TreeView1.Nodes(lNode).Expanded = True
              lCurrentNode = lNode
              Exit For
           End If
        Next

     Next

  End If

End Sub
'====================

Signature

Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
In Loving Memory - http://www.vbsight.com/Remembrance.htm

MAB - 29 Mar 2007 02:08 GMT
I'm sure this will work.  I'll give it a wurle when I get a chance.

Thanks a bunch Ken and Scott.  


> > Isn't that what I said?
>
[quoted text clipped - 62 lines]
> End Sub
> '====================
MAB - 29 Mar 2007 16:56 GMT
I ended up using the data populated in the selected Node's FullPath property
which is similar to what you did.

Private Sub cmdOk_Click()
   SaveSetting "BBH", "DrawingAccess", "PreviousFullPath",
TreeView1.SelectedItem.FullPath
   Me.Hide
End Sub

'This is executred in Form_Load
Sub ExpandToPreviousFolder()
   Dim sFullPath As String
   Dim sNodes() As String
   Dim lNode As Long
   Dim lLevel As Long
   Dim lCurrentNode As Long
   
   sFullPath = GetSetting("BBH", "DrawingAccess", "PreviousFullPath", "")
   If sFullPath <> "" Then
      sNodes = Split(sFullPath, "\")
      lCurrentNode = 1
      For lLevel = 0 To UBound(sNodes)
         For lNode = lCurrentNode To TreeView1.Nodes.Count
            If TreeView1.Nodes(lNode).Text = sNodes(lLevel) Then
               TreeView1.Nodes(lNode).Selected = True
               TreeView1.Nodes(lNode).Expanded = True
               lCurrentNode = lNode
               Exit For
            End If
         Next
      Next
   End If
End Sub

Thanks again Ken.

> > Isn't that what I said?
>
[quoted text clipped - 62 lines]
> End Sub
> '====================
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.