|
-
Jun 22nd, 2000, 03:28 AM
#1
Thread Starter
Addicted Member
Hi all,
I'am using a commondialog to display the DIR on a hard drive in one of my apps. I do this with the showopen property but the problem is that I don't want the user to select FILES, only DIRs.
I DON'T WANT THE COMMONDIALOG TO SHOW FILES, JUST DIRs.
I'am pretty sure there is a way to do so, (filter maybe),
any ideas ?
Thanks for your help
-
Jun 22nd, 2000, 03:37 AM
#2
This is not the best way, but you can set the filter to some very unsual file extention so it wil not show any files. For example: rgsroigfs
-
Jun 22nd, 2000, 03:38 AM
#3
Member
Hmmmmmm........Well I don't think folders have certain file extensions, but you could just make up a file extension that doesn't exist....which would always show just the folders.
dlg1.Filter = "All Folders|*.abcdef|"
-
Jun 22nd, 2000, 03:44 AM
#4
Thread Starter
Addicted Member
Thanks guys but whats with the command button,
it won't come enabled if I've specified a file extension
but haven't selected any files ???
We are close but, again a bit too far...
-
Jun 22nd, 2000, 03:48 AM
#5
Member
Ummmmm....what command button?
-
Jun 22nd, 2000, 03:51 AM
#6
If you want to load it when you press a CommandButton, use this code.
Code:
Private Sub Command2_Click()
CommonDialog1.filename = ""
CommonDialog1.Filter = "|*.gufgfdgd" ' our weird extention
CommonDialog1.ShowOpen
End Sub
-
Jun 22nd, 2000, 03:55 AM
#7
Thread Starter
Addicted Member
the ok (open) button, it the component that controls
the enabled or not feature...
-
Jun 22nd, 2000, 04:00 AM
#8
Lively Member
I think Vince is talking about the Open button in the common dialog box. To get around this problem, use a ShowSave rather than a ShowOpen, and set the filename to something like 'Select a Location', then when the result comes back from the common dialog, filter out the filename and just use the path.
-
Jun 22nd, 2000, 04:13 AM
#9
Lively Member
If you just want to browse for a folder, put this function in a module in your project.
Code:
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Declare Function SHGetPathFromIDList Lib "SHELL32.DLL" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "SHELL32.DLL" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long 'ITEMIDLIST
Public Function BrowseFolder(f As Form, szDialogTitle As String) As String
Dim x As Long, BI As BROWSEINFO, dwIList As Long, szPath As String, wPos As Integer
BI.hOwner = f.hwnd
BI.lpszTitle = szDialogTitle
BI.ulFlags = BIF_RETURNONLYFSDIRS
dwIList = SHBrowseForFolder(BI)
szPath = Space$(512)
x = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If x Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = ""
End If
End Function
and call it from your form with:
Code:
Return=BrowseFolder(Me,"Some title")
Then the variable Return will show what folder the user selected.
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
|