-
September 16th, 2002, 12:55 AM
#1
How to select a folder in common dialog control
How to Select a folder in Common dialog control?
I know we can do this with DisListBox but i want to do it with Common Dialog Control
-
September 16th, 2002, 01:05 AM
#2
I dont think there is a possibility to do this with the Common Dialog control. (At least I didnt find a flag how to do it.)
But you could try to build your own CDlg Control (or Form) that has the same look and feel as the Microsofts where you are able to do this feature. But as I understood you you dont really want to do it.
Another possiblility is to try to find any control in the web that makes you do it. Just try a search!!!
Good luck
mfg Ungi
Music, music and VB. VB is like music: You never know how it is interpreted.
-
September 16th, 2002, 01:09 AM
#3
As far as I know U can't But u can use Windows API to solve this poblem
Here is the Code.
Bas COde
Code:
'This module contains all the declarations to use the
'Windows 95 Shell API to use the browse for folders
'dialog box. To use the browse for folders dialog box,
'please call the BrowseForFolders function using the
'syntax: stringFolderPath=BrowseForFolders(Hwnd,TitleOfDialog)
'
'For contacting information, see other module
Option Explicit
Public Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String
'declare variables to be used
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo
'initialise variables
With udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With
'Call the browse for folder API
lpIDList = SHBrowseForFolder(udtBI)
'get the resulting string path
If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)
If iNull Then sPath = Left$(sPath, iNull - 1)
End If
'If cancel was pressed, sPath = ""
BrowseForFolder = sPath
End Function
Form Code
Private Sub cmdServerBrowse_Click()
txtDatabasePath.Text = BrowseForFolder(hwnd, "Please select a Server folder.")
End Sub
[Cimperiali colorized and indented for better reading]
Last edited by Cimperiali; December 7th, 2002 at 05:41 AM.
-
September 16th, 2002, 01:11 AM
#4
mfg Ungi
Music, music and VB. VB is like music: You never know how it is interpreted.
-
September 16th, 2002, 01:13 AM
#5
I got this from code guru sometime back
-
September 16th, 2002, 02:05 AM
#6
thats it thanx
-
April 1st, 2003, 06:52 AM
#7
Hi Dinesh123,
This probably is a very simple question but can you tell me how to combine the code you gave in this thread with for example this code?
--------------------------------------------------------------------------
DoCmd.TransferText acExportMerge, , "Persoon", "C:\"
--------------------------------------------------------------------------
This code exports my database as a txt file into my C:\
Only in stead of "C:\" I want to use the browse function.
Many thanks,
Jasper
Flying is to throw yourself on the ground and miss
-
April 1st, 2003, 08:13 AM
#8
Code:
Dim strFolder as String
strFolder= BrowseForFolder(hwnd, "Please select a Server folder.")
If len(strFolder)>0 then
DoCmd.TransferText acExportMerge, , "Persoon", strFolder
End If
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
April 1st, 2003, 08:54 AM
#9
Hi Cimperiali,
Pffhhhh, thank you so much. I was nearly eating my desk out of frustration there.
Jasper
Flying is to throw yourself on the ground and miss
-
April 13th, 2004, 02:32 AM
#10
That's good,i search this code for a long time.
-
October 11th, 2005, 04:16 AM
#11
Re: How to select a folder in common dialog control
Is there a way, how to specify the default folder that is to be selected, when the dialog is shown?
-
October 11th, 2005, 05:42 AM
#12
Re: How to select a folder in common dialog control
Originally Posted by jsiii
Is there a way, how to specify the default folder that is to be selected, when the dialog is shown?
Yes there is!
Code:
CommonDialog1.InitDir = "C:\My Documents"
CommonDialog1.ShowOpen
-
August 7th, 2007, 10:32 AM
#13
Re: How to select a folder in common dialog control
I tried and it works fine.
The window has the title "Ordner suchen" and the buttons have the label "OK" and "Abbrechen".
It seems that the language is taken from the system properties (I'm a german).
Is it possible to change the language inside the window?
I need to localize my software (changing the language in the code) without to be pressed to change the system properties.
-
September 26th, 2007, 10:36 AM
#14
Re: How to select a folder in common dialog control
thanks for coding
but any one can give me this as a component
it will be useful for me more than copy-paste option
-
September 26th, 2007, 10:49 AM
#15
Re: How to select a folder in common dialog control
yavasoft, please do not reply to very old threads, this is the second old thread you are reviving. If you have a question, rather use the "New Thread" button on the Forum.
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
|