предложил свой новый безDLL'ный метод... хотя он и позволяет использовать все возможности диалоговых окон (в т.ч. Explorer style) по причине нехватки времени пока тупо перегнал
Код: Выделить всё
#include
#include
Global Const $BFFM_INITIALIZED = 1
Global Const $BFFM_SETSELECTION = $WM_USER + 102
Global Const $BIF_BROWSEFORCOMPUTER = 0x1000 ; Only return computers
Global Const $BIF_BROWSEFORPRINTER = 0x2000 ; Only allow the selection of printers
Global Const $BIF_BROWSEINCLUDEFILES = 0x4000 ; The browse dialog box will display files as well as folders
Global Const $BIF_DONTGOBELOWDOMAIN = 0x2 ; Do not include network folders below the domain level
Global Const $BIF_EDITBOX = 0x10 ; Include an edit control in the browse dialog box
Global Const $BIF_RETURNONLYFSDIRS = 0x1 ; Only return file system directories
Global Const $BIF_ALLOLDSTYLEFLAGS = BitOR ($BIF_BROWSEFORCOMPUTER, $BIF_BROWSEFORPRINTER, $BIF_BROWSEINCLUDEFILES, $BIF_DONTGOBELOWDOMAIN, $BIF_EDITBOX, $BIF_RETURNONLYFSDIRS)
; Simple GUI for sample
$hWndMain = GUICreate ("Test GUI", 200, 45, -1, -1)
$Button_1 = GUICtrlCreateButton ("Select folder", 55, 10)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
$res = _FileSelectFolderOldStyle ('Here the prompt', 0, $BIF_RETURNONLYFSDIRS, 'C:\_1', $hWndMain)
MsgBox (0, "Your choise:", $res)
EndSelect
Wend
; Initial folder procedure
Func _BrowseCallbackProc ($hWnd, $Msg, $wParam, $lParam)
If $Msg = $BFFM_INITIALIZED Then
$ret = DllCall ("user32.dll", "int", "SendMessage", _
"hwnd",$hWnd, "int", $BFFM_SETSELECTION, "int", 1, "ptr", $lParam )
EndIf
Return 0
EndFunc ;==> _BrowseCallbackProc
Func _FileSelectFolderOldStyle ($text = '', $root = 0, $flags = 0, $iniDir = '', $hwnd = 0)
Local $ret, $pidl, $res = ''
; Creating Structures
Local $ubi = DllStructCreate ("hwnd;ptr;ptr;ptr;int;ptr;ptr;int") ; BROWSEINFO
Local $utl = DllStructCreate ("char[512],char") ; Browse text
Local $urs = DllStructCreate ("char[260]") ; MAX_PATH
Local $ulf = BitAnd ($flags, $BIF_ALLOLDSTYLEFLAGS) ; Supported flags
; Filling structures
DllStructSetData ($utl, 1, $text)
DllStructSetData ($ubi, 1, $hwnd)
DllStructSetData ($ubi, 3, DllStructGetPtr($urs))
DllStructSetData ($ubi, 4, DllStructGetPtr($utl))
DllStructSetData ($ubi, 5, $ulf)
If ($iniDir '') And ($hwnd 0) Then
Local $udr = DllStructCreate ("char[" & StringLen ($iniDir)+1 & "]")
DllStructSetData ($udr, 1, $iniDir)
Local $pBrowseCallbackProc = _DllCallBack("_BrowseCallbackProc","hwnd;uint;long;ptr") ; return function pointer
DllStructSetData ($ubi, 6, $pBrowseCallbackProc)
DllStructSetData ($ubi, 7, DllStructGetPtr($udr))
EndIf
$ret = DllCall ("shell32.dll", "ptr", "SHGetSpecialFolderLocation", _
"int", 0 , "int", $root , "ptr", DllStructGetPtr($ubi, 2) )
If $ret[0]=0 Then
$pidl = DllCall ("shell32.dll", "ptr", "SHBrowseForFolder", "ptr", DllStructGetPtr ($ubi)) ; Start browse window
If $pidl[0] Then
$ret = DllCall ("shell32.dll", "int", "SHGetPathFromIDList", _
"ptr", $pidl[0], "ptr", DllStructGetPtr ($urs))
If $ret[0] Then $res = DllStructGetData ($urs, 1)
DllCall ("ole32.dll", "int", "CoTaskMemFree", "ptr", $pidl[0]) ; clear memory
EndIf
DllCall ("ole32.dll", "int", "CoTaskMemFree", "ptr", DllStructGetData ($ubi, 2))
EndIf
_DllCallBack_Free ($pBrowseCallbackProc) ; clear memory
Return $res
EndFunc ;==> _FileSelectFolderOldStyle
http://www.autoitscript.com/forum/in...=post&id=15441