?
Solved

Graphically displaying directory structures

Posted on 2007-10-10
9
Medium Priority
?
422 Views
Last Modified: 2012-05-05
I'm looking to graphically display a directory structure, any ideas how I could do this?

Thanks
0
Comment
Question by:jmingo
7 Comments
 
LVL 17

Expert Comment

by:inthedark
ID: 20049197
Is this a real project or just an exercise? I ask becuase how I would ansewer this question would depend on how much you wanted to learn.

If you really wanted to make something very special I would create a user control and place a picture box within the control, then you can make the folder look exactly as you wish and end up with a highly reusable and portable feature.
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20049320
Is Treeview not helping you?
0
 

Author Comment

by:jmingo
ID: 20050576
i want a more graphical view than i think treeview can do. or maybe it can do more???

its for a possible project...just trying to get an idea of how i should start.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:cup
ID: 20051777
There are two problems: getting the directory structure and putting it into a tree view.  

I'd concentrate on getting the directory structure first.  You have to watch out for the silly things like . and ..  If you try expanding those, you'll get into an infinite loop.

Only start looking at the treeview when you've gotten the directory structure.  That way, if you hit a problem, you'll know it is to do with the treeview: not getting the directory structure.

Tree view will accept tab separated strings to create a merged list and tree view so you could display the structure with the properties of each entry.
0
 
LVL 17

Accepted Solution

by:
inthedark earned 500 total points
ID: 20055258
You have only allowed 125 points for quite a complex issue so time available is limited.

OK so let us break down this problem into the following areas:

1) Obtain the data for the current folder

2) Display the data

3) Responds to the operator keyboard and mouse events

----------------------------------------
1) Get the data for the current folder

See this example to obtain files

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20996946.html#a11125862

I will post the modification that allows you to get the folders.

So you would need code like:

Dim Folders
Folders = GetFolders(msCurrentFolder) ' return array of folders

And to get the files
Files = GetFiles(msCurrentFolder)

The GetFiles function can also return length of file and file date info see then function

-------------------------------------------
2) To display the data in a window you would need code like this:

In this example we will use a picture box within a picture box, I assume you know how to handle scrolling of a picture box within a picture box (picVP inside picOuter) and how to use scroll bars etc. Set the SacelMode of the picture boxes to pixels - this is essential for graphics apps. Also set Autoredraw to true.

You also need to calculate how many pixcels you want to allow for each folder/file line.

dim mlLineHeight As Long ' module level variable

mlLineHeight = picVP.TextFeild("ANY TEXT") * 1.2

Sub GetAndDisplayFolders()

Dim lCount As Long
dim lMax As Long
lMax = UBound(Folders)

picVP.Height = (lMax + 1) * mlLineHeight

For lCount = 0 To lMax
    DisplayFolder lCount, Folders(lc) ' pass current counter and folder name to sub for display

End Sub

Private Sub DisplayFolder(plPos As Long, psName As String)

Dim lYPos as Long
lYPos = plPos * mlLineHeight

' display a graphic as start of line
picVP.PaintPicture picFolderImage,  0, lYpos

' Display the text
picVP.CurrentY = lYPos
picVP.CurrentX = picFolderImage.Width
picVP.Print psName;  

End Sub

Display of files is almost exatly the same.

-------------------------------------------------------
3) Respond to the operator keyboard and mouse events

In your form you setup KeyPreview property to true

Then when operator presses keys you get KeyDow, KeyUp and KeyPress events

Also you store MouseMove data which tells you whene the mouse is currently within the picVP. If you get doubleclick or click events you can work out which line was clicked.

Private Sub VP_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If mbInPopup Then Exit Sub

mlMouseY = Y
mlMouseX = X
mlMouseButton = Button
mlMouseShift = Shift

Exit Sub

Here is a sample click event

Private Sub VP_Click()

zReviseMouseStatus ' calculate where mouse is

msgbox "You are in row: "+cstr(mlMoudeDownInRow)

End Sub


Private Sub zReviseMouseStatus()

' Calculate which rows and columns the mouse is currently in

If Not mbActive Then Exit Sub
'If Not mbMouseDown Then Exit Sub
If mCurrentView <> ghGrid Then
    If Not mbMouseDown Then
        mbSelectionInForce = False
        mbColumnSelect = False
        mbGridSelect = False
        mbRowSelect = False
        mbMouseToFar = False
        Exit Sub
    End If
   
    zGetColumnValuesForm mlMouseX, mlMouseY, mlMouseInCol
    If mlMouseInCol >= 0 Then
        If mlMouseShift And 2 Then
            mbSelectionInForce = True
            mbColumnSelect = True
            mbGridSelect = False
            mbRowSelect = False
        End If
    End If
   
Else
    mbSelectionInForce = False
       
    If mlMouseY <= mlHeadingHeight Then
        mbColumnSelect = True
        mbSelectionInForce = mbMouseDown
    Else
        mbColumnSelect = False
    End If
   
    If mlMouseX < 0 Then
        If mbColumnSelect Then
            mbColumnSelect = False
            mbGridSelect = True
            mbSelectionInForce = mbMouseDown
            mbRowSelect = False
        Else
            mbGridSelect = False
            mbRowSelect = True
            mbSelectionInForce = mbMouseDown
        End If
    Else
        mbGridSelect = False
        mbRowSelect = False
    End If


    mlMouseInRow = mlTopRow + Int((mlMouseY - mlHeadingHeight) / mlRowHeight)
    If mlMouseInRow < 0 Then
        mlMouseInRow = -1
    End If
    If mlMouseInRow > mlRows Then
        mlMouseInRow = mlRows
    End If
    zGetColumnValues mlMouseX, mlMouseNearCol, mlMouseInCol
   
    If Not mbColumnSelect And mbColumnSelectInForce Then
        zDisplayGrid
        mbColumnSelectInForce = False
    End If
   
End If
End Sub

Above is all you need to know in terms of how to code all you have to do is figure out how to handle variable folder heights as a folder may be either open or closed.

But at least you can make a stab at how major the job is, I would allow about 4 weeks to do a good job.




0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20060543
Try OsenXpSuite 2006 - A third party control that will make your application eye catching. Not only for displaying your need and for all your imagination and expectations. Have a look on it
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20379794
Forced accept.

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question