|
-
May 23rd, 2005, 07:29 AM
#1
Thread Starter
New Member
List Boxes Aarrggh!! Help
Hello,
Right i have two forms. One the first is a drive list box. I want this to only display hard-disks, not CDROMS or A:\ or Removeable drives. Anyone know how to do this?
Plus on my form2 is a directory list box, i want this list box to show the users chosen hard-disk, open at "Documents and Settings".. So if a user chooses "c:\" the directory list box on form2 will open at "C:\Documents and Settings".. Anyone know how to do this?..
PLEASE HELP.
MAIL ME HERE
-
May 23rd, 2005, 07:39 AM
#2
Re: List Boxes Aarrggh!! Help
-
May 23rd, 2005, 08:30 AM
#3
Re: List Boxes Aarrggh!! Help
Hi jonnie and welcome to VBForums!
Imfortunately what you described doesn't make much sense to me - if you restrict user from browsing anything but his/her personal folders then why ever bother showing navigation tools such drive/dir listboxes. Also "Documents And Setttings" is Windows special folder and it could have a different name on different system so you need to find it. The following sample is a modified sample from allapi network - it demonstrates how to find personal folder. You may use that path throughout the project but variable will have to be declare as Public at the module level.
VB Code:
Option Explicit
Private Const CSIDL_PERSONAL = &H5
Private Const ERROR_SUCCESS = 0&
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
Private Sub Command1_Click()
Dim strPath$
strPath = GetSpecialFolder(Me.hwnd, CSIDL_PERSONAL)
Debug.Print "Desktop folder: " & strPath
End Sub
Public Function GetSpecialFolder(hwnd As Long, CSIDL As Long) As String
'========================================================================
Dim pidl As Long
Dim Pos As Long
Dim sPath As String
'fill the pidl with the specified folder item
If SHGetSpecialFolderLocation(hwnd, CSIDL, pidl) = ERROR_SUCCESS Then
'initialize & get the path
sPath = Space$(260)
If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then
'check for a null
Pos = InStr(sPath, Chr$(0))
If Pos Then 'strip it
GetSpecialFolder = Left$(sPath, Pos - 1)
End If
Call CoTaskMemFree(pidl)
End If
End If
End Function
-
May 26th, 2005, 05:47 AM
#4
Thread Starter
New Member
Re: List Boxes Aarrggh!! Help
I have sorted out opening the dirlistbox at "chosen source drive"\Documents and settings,
NOW,
I want to make the UNC of [chosenSourceDrive]\Documents and Settings to be the top most folder in the dirListBox.
Anyone know how to do this?
Would I use the TopIndex property and set a string value to it?
Such as... (pseudo)
'Source Drive Form
#################
text1.text = [chosen source drive letter] + \Documents and Settings
'Text 1 Now reads "C:\Documents and Settings
'My dirListBox on my "Choose your username" form is set to that path.
'UserName Form
############
'OK Heres the bit i'm struggling with, so take the info that there are two
'forms, on the first one, the user chooses a drive and the drive letter plus
'\documents and settings is set to a text box. That text box is read into
'the dirListBox as the path, hecnce the dirListBox opens at "drive" +
'\documents and setting
'You See... (take the symbol "@" to mean a folder icon)
@c:\
@Documents and Settings
@username1
@username2
@username3
i want the usernames to be the top most folder so it just shows
@username1
@username2
@username3
Any one help?
-
May 26th, 2005, 06:11 AM
#5
Re: List Boxes Aarrggh!! Help
 Originally Posted by jonniehack
I have sorted out opening the dirlistbox at "chosen source drive"\Documents and settings,
NOW,
I want to make the UNC of [chosenSourceDrive]\Documents and Settings to be the top most folder in the dirListBox.
Anyone know how to do this?
Would I use the TopIndex property and set a string value to it?
Such as... (pseudo)
'Source Drive Form
#################
text1.text = [chosen source drive letter] + \Documents and Settings
'Text 1 Now reads "C:\Documents and Settings
'My dirListBox on my "Choose your username" form is set to that path.
'UserName Form
############
'OK Heres the bit i'm struggling with, so take the info that there are two
'forms, on the first one, the user chooses a drive and the drive letter plus
'\documents and settings is set to a text box. That text box is read into
'the dirListBox as the path, hecnce the dirListBox opens at "drive" +
'\documents and setting
'You See... (take the symbol "@" to mean a folder icon)
@c:\
@Documents and Settings
@username1
@username2
@username3
i want the usernames to be the top most folder so it just shows
@username1
@username2
@username3
Any one help?
You'd probably have to do it through API - I'm not shure that VB has a way to re-order thigs in a list box as a built in method.
Did you try RhinoBull's method, it could be much easier 
Cheers,
RyanJ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|