Jump to content

Integrated Browse / Run Dialog / Treeview


Recommended Posts

I am writing a program for remote management and I'm trying to integrate a tree-view style browse into the client to browse for files on the remote computer, but I do not want to open a separate window like FileOpenDialog uses. Any suggestions or example code that I can work from?

Link to comment
Share on other sites

I am writing a program for remote management and I'm trying to integrate a tree-view style browse into the client to browse for files on the remote computer, but I do not want to open a separate window like FileOpenDialog uses. Any suggestions or example code that I can work from?

Perhaps this can help you.

http://www.autoitscript.com/forum/index.ph...st&p=580714

or maybe this

http://www.autoitscript.com/forum/index.ph...st&p=687813

Edited by spudw2k
Link to comment
Share on other sites

It didn't really help me, so I'm going to provide the code I wrote for other people to use.

Please post any improvements to the code you make.

Here is the treeview

$tree = GUICtrlCreateTreeView($GUIWidth*.6153, ($GUIHeight/2)-20,390, $GUIHeight*.4375, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)

Here, the server receives the drivegetdrive() from the client...

$drive = StringTrimRight(StringTrimLeft($datas[$o],7),7)
                $drives = StringSplit($drive,'|')
                _GUICtrlTreeView_BeginUpdate($tree)
                for $i = 2 to $drives[0] step 1
                    Switch StringTrimLeft($drives[$i],2)
                        Case "Unknown";
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 5, 5)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                        Case "Removable";
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 6, 6)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                        Case "Fixed";
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 7, 7)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                        Case "Network";
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 8, 8)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                        Case "CDROM";
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 9, 9)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                        Case "RAMDisk"
                            $temp = _GUICtrlTreeView_Add($tree, 0, StringLeft($drives[$i],2), 11, 11)
                            TCPSend($socket[$sender][0],'¦FiLeLST' & $temp  & '|' & StringLeft($drives[$i],StringInStr($drives[$i],':')) & '¦')
                    EndSwitch
                Next
                _GUICtrlTreeView_EndUpdate($tree)

Here is the function that is used when the client sends the data for a subdirectory

Func TreeViewAdd($name, $parent)
    _GUICtrlTreeView_BeginUpdate($tree)
    Select
        Case StringLeft($name,1) = '\'; Directory
            _GUICtrlTreeView_AddChild($tree, $parent, StringTrimLeft($name,1), 4, 4)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'txt' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'doc' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'rtf' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'ini';Documents
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 2, 2)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'exe' ;Exes
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 3, 3)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'bat' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'vbs' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'cmd'; scripts
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 10, 10)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mov' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'wmv' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mp4' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mpg' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'avi' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'asf' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'asx' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'flv' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'm4v';movies
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 12, 12)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mp3' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'wav' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'wma' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'aac' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'm3u' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'm4a' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mid' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mp1' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mp2'; audio
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 13, 13)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'lnk'; shortcut
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 14, 14)
        Case StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'jpg' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'peg' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'gif' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'tif' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'm4a' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'mid' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'gif' or StringLower(StringTrimLeft($name,StringInStr($name,'.',-1,-1))) = 'png'; images
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 15, 15)
        Case Else; other / 1
            _GUICtrlTreeView_AddChild($tree, $parent, $name, 1, 1)
    EndSelect
    _GUICtrlTreeView_EndUpdate($tree)
EndFunc

this allows for double clicking on the treeview to be linked to the next function...

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event
    If $wParam = $tree Then
        $tagNMHDR = DllStructCreate("int;int;int", $lParam)
        $event = DllStructGetData($tagNMHDR, 3)
        If $event = $NM_DBLCLK Then TreeClick()
    EndIf
EndFunc  ;==>WM_Notify_Events

this sends a request to the server for a directory listing of the double clicked folder

Func TreeClick()
    Opt("GUIDataSeparatorChar","\")
    TCPSend($socket[0][0],'¦FiLeLST' & _GUICtrlTreeView_GetSelection($tree)  & '|' & _GUICtrlTreeView_GetTree($tree,_GUICtrlTreeView_GetSelection($tree)) & '¦')
    Opt("GUIDataSeparatorChar","|")
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...