Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

TVExplorer UDF


  • Please log in to reply
57 replies to this topic

#1 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 08 February 2011 - 03:56 PM

LAST VERSION - 1.2
09-May-11

Unlike this, here is a fully ready UDF library. The library allows you to create TreeView Explorer controls that displays a tree of files and folders for the specified root folder with the specified parameters. A TreeView Explorer controls is self-contained GUI controls that do not require you any further doing. Note that TTVExplorer UDF requires WinAPIEx UDF version 3.2 or later.

To create a TreeView Explorer control, just call the _GUICtrlTVExplorer_Create() function. And that's it. If you want to be notified about events such as the changing selection, the beginning and ending of the updating TreeView Explorer control, the mounting and unmounting removeable drives, etc., you must specify a user function to retrieve these notifications, like WM-functions. How it works is shown in the following example. This library can work in "Loop" and "OnEvent" GUI modes. If the "GUIOnEventMode" option is set to 0, you should use _GUICtrlTVExplorer_GetMsg() instead of native GUIGetMsg() function, otherwise, the TreeView Explorer controls will not work. In using, these two functions are completely equivalent. A more detailed description of all functions you'll find inside the library.

As usualy, I will be glad to any feedback and suggestions.


TVExplorer.png



Available functions

Spoiler


TVExplorer UDF Library v1.2
Previous downloads: 544

Attached File  TVExplorer.zip   15.08KB   1607 downloads


Example 1

AutoIt         
#Include <GUIConstantsEx.au3> #Include <GUITreeView.au3> #Include <TVExplorer.au3> #Include <TreeViewConstants.au3> #Include <WindowsConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $Path, $Style If Not _WinAPI_DwmIsCompositionEnabled() Then     $Style = $WS_EX_COMPOSITED Else     $Style = -1 EndIf $hForm = GUICreate('TVExplorer UDF Example', 700, 736, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style) GUISetIcon(@WindowsDir & '\explorer.exe') $Input[0] = GUICtrlCreateInput('', 20, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[1] = GUICtrlCreateInput('', 360, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[2] = GUICtrlCreateInput('', 20, 378, 660, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') For $i = 0 To 2     _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))     _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i]) Next $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO') GUIRegisterMsg($WM_SIZE, 'WM_SIZE') HotKeySet('{F5}', '_TVRefresh') GUISetState() _GUICtrlTVExplorer_Expand($hTV[0], @ProgramFilesDir & '\AutoIt3') _GUICtrlTVExplorer_Expand($hTV[1]) While 1     Switch _GUICtrlTVExplorer_GetMsg()         Case $GUI_EVENT_CLOSE             GUIDelete()             _GUICtrlTVExplorer_DestroyAll()             Exit         Case $Dummy             $Path = _GUICtrlTVExplorer_GetSelected($hFocus)             _GUICtrlTVExplorer_AttachFolder($hFocus)             _GUICtrlTVExplorer_Expand($hFocus, $Path, 0)             $hFocus = 0     EndSwitch WEnd Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)     Switch $iMsg         Case $TV_NOTIFY_BEGINUPDATE             GUISetCursor(1, 1)         Case $TV_NOTIFY_ENDUPDATE             GUISetCursor(2)         Case $TV_NOTIFY_SELCHANGED             For $i = 0 To 2                 If $hTV[$i] = $hWnd Then                     _TVSetPath($Input[$i], $sPath)                     ExitLoop                 EndIf             Next         Case $TV_NOTIFY_DBLCLK             ; Nothing         Case $TV_NOTIFY_RCLICK             ; Nothing         Case $TV_NOTIFY_DELETINGITEM             ; Nothing         Case $TV_NOTIFY_DISKMOUNTED             ; Nothing         Case $TV_NOTIFY_DISKUNMOUNTED             ; Nothing     EndSwitch EndFunc   ;==>_TVEvent Func _TVSetPath($iInput, $sPath)     Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2)     If GUICtrlRead($iInput) <> $Text Then         GUICtrlSetData($iInput, $Text)     EndIf EndFunc   ;==>_TVSetPath Func _TVRefresh()     Local $hWnd = _WinAPI_GetFocus()     For $i = 0 To 2         If $hTV[$i] = $hWnd Then             If Not $hFocus Then                 $hFocus = $hWnd                 GUICtrlSendToDummy($Dummy)             EndIf             Return         EndIf     Next     HotKeySet('{F5}')     Send('{F5}')     HotKeySet('{F5}', '_TVRefresh') EndFunc   ;==>_TVRefresh Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)     Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)     Switch $hWnd         Case $hForm             DllStructSetData($tMMI, 'MinTrackSize', 428, 1)             DllStructSetData($tMMI, 'MinTrackSize', 450, 2)     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_GETMINMAXINFO Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)     Local $WC, $HC, $WT, $HT     Switch $hWnd         Case $hForm             $WC = _WinAPI_LoWord($lParam)             $HC = _WinAPI_HiWord($lParam)             $WT = Floor(($WC - 60) / 2)             $HT = Floor(($HC - 116) / 2)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[0]), 20, 48, $WT, $HT)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[1]), $WT + 40, 48, $WC - $WT - 60, $HT)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[2]), 20, $HT + 96, $WC - 40, $HC - $HT - 116)             GUICtrlSetPos($Input[0], 20, 20, $WT)             GUICtrlSetPos($Input[1], $WT + 40, 20, $WC - $WT - 60)             GUICtrlSetPos($Input[2], 20, $HT + 68, $WC - 40)             For $i = 0 To 2                 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))             Next             Return 0     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_SIZE


Example 2 (OnEvent mode)

AutoIt         
#Include <GUIConstantsEx.au3> #Include <GUITreeView.au3> #Include <TVExplorer.au3> #Include <TreeViewConstants.au3> #Include <WindowsConstants.au3> #Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Opt('GUIOnEventMode', 1) Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $Style If Not _WinAPI_DwmIsCompositionEnabled() Then     $Style = $WS_EX_COMPOSITED Else     $Style = -1 EndIf $hForm = GUICreate('TVExplorer UDF Example', 700, 736, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style) GUISetOnEvent($GUI_EVENT_CLOSE, '_GUIEvent') GUISetIcon(@WindowsDir & '\explorer.exe') $Input[0] = GUICtrlCreateInput('', 20, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[1] = GUICtrlCreateInput('', 360, 20, 320, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') $Input[2] = GUICtrlCreateInput('', 20, 378, 660, 19) GUICtrlSetState(-1, $GUI_DISABLE) $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') For $i = 0 To 2     _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))     _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i]) Next $Dummy = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, '_GUIEvent') GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO') GUIRegisterMsg($WM_SIZE, 'WM_SIZE') HotKeySet('{F5}', '_TVRefresh') GUISetState() _GUICtrlTVExplorer_Expand($hTV[0], @ProgramFilesDir & '\AutoIt3') _GUICtrlTVExplorer_Expand($hTV[1]) While 1     Sleep(1000) WEnd Func _GUIEvent()     Local $Path     Switch @GUI_CtrlId         Case $GUI_EVENT_CLOSE             GUIDelete()             _GUICtrlTVExplorer_DestroyAll()             Exit         Case $Dummy             $Path = _GUICtrlTVExplorer_GetSelected($hFocus)             _GUICtrlTVExplorer_AttachFolder($hFocus)             _GUICtrlTVExplorer_Expand($hFocus, $Path, 0)             $hFocus = 0     EndSwitch EndFunc   ;==>_GUIEvent Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)     Switch $iMsg         Case $TV_NOTIFY_BEGINUPDATE             GUISetCursor(1, 1)         Case $TV_NOTIFY_ENDUPDATE             GUISetCursor(2)         Case $TV_NOTIFY_SELCHANGED             For $i = 0 To 2                 If $hTV[$i] = $hWnd Then                     _TVSetPath($Input[$i], $sPath)                     ExitLoop                 EndIf             Next         Case $TV_NOTIFY_DBLCLK             ; Nothing         Case $TV_NOTIFY_RCLICK             ; Nothing         Case $TV_NOTIFY_DELETINGITEM             ; Nothing         Case $TV_NOTIFY_DISKMOUNTED             ; Nothing         Case $TV_NOTIFY_DISKUNMOUNTED             ; Nothing     EndSwitch EndFunc   ;==>_TVEvent Func _TVSetPath($iInput, $sPath)     Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2)     If GUICtrlRead($iInput) <> $Text Then         GUICtrlSetData($iInput, $Text)     EndIf EndFunc   ;==>_TVSetPath Func _TVRefresh()     Local $hWnd = _WinAPI_GetFocus()     For $i = 0 To 2         If $hTV[$i] = $hWnd Then             If Not $hFocus Then                 $hFocus = $hWnd                 GUICtrlSendToDummy($Dummy)             EndIf             Return         EndIf     Next     HotKeySet('{F5}')     Send('{F5}')     HotKeySet('{F5}', '_TVRefresh') EndFunc   ;==>_TVRefresh Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)     Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)     Switch $hWnd         Case $hForm             DllStructSetData($tMMI, 'MinTrackSize', 428, 1)             DllStructSetData($tMMI, 'MinTrackSize', 450, 2)     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_GETMINMAXINFO Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)     Local $WC, $HC, $WT, $HT     Switch $hWnd         Case $hForm             $WC = _WinAPI_LoWord($lParam)             $HC = _WinAPI_HiWord($lParam)             $WT = Floor(($WC - 60) / 2)             $HT = Floor(($HC - 116) / 2)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[0]), 20, 48, $WT, $HT)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[1]), $WT + 40, 48, $WC - $WT - 60, $HT)             GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[2]), 20, $HT + 96, $WC - 40, $HC - $HT - 116)             GUICtrlSetPos($Input[0], 20, 20, $WT)             GUICtrlSetPos($Input[1], $WT + 40, 20, $WC - $WT - 60)             GUICtrlSetPos($Input[2], 20, $HT + 68, $WC - 40)             For $i = 0 To 2                 _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))             Next             Return 0     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_SIZE

Edited by Yashied, 10 December 2013 - 02:36 PM.

  • iFFgen likes this







#2 UEZ

UEZ

    Never say never

  • MVPs
  • 4,882 posts

Posted 08 February 2011 - 04:04 PM

Hi Yashied (Jack),

nice work as usual. Can I use it also for adding other data to treeview?

Br,
UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#3 water

water

    ?

  • MVPs
  • 15,346 posts

Posted 08 February 2011 - 04:04 PM

Wow - very impressive :)
UDFs:
Active Directory (NEW 2014-07-21 - Version 1.4.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

#4 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 08 February 2011 - 04:08 PM

Can I use it also for adding other data to treeview?

Not, only one folder or list of drives.

#5 CodyBarrett

CodyBarrett

    I LOVE Juicy Fruit!!!

  • Active Members
  • PipPipPipPipPipPip
  • 1,225 posts

Posted 08 February 2011 - 05:07 PM

pretty cool :)

#6 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,433 posts

Posted 08 February 2011 - 05:08 PM

Yashied,

I hate you - I have just spent a week writing a UDF which does this sort of thing with a native treeview and you produce this! :idiot:

Well up to your usual standard. :)

As I see you are using FileFindFirst/NextFile I imagine it would not be too hard to limit the displayed tree to folders only or to filter the files displayed in the same manner as manner as my RecFileListToArray UDF - or am I mistaken? ;)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#7 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 08 February 2011 - 07:03 PM

Here was important for me only the speed of processing.

#8 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,433 posts

Posted 08 February 2011 - 07:06 PM

Yashied,

Any objections if I play with it to see what I can produce along those lines? :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#9 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 08 February 2011 - 07:08 PM

Ofcourse, no problem.

:)

Edited by Yashied, 08 February 2011 - 07:09 PM.


#10 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,433 posts

Posted 08 February 2011 - 07:13 PM

Yashied,

Спасибо, мой друг. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#11 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,679 posts

Posted 09 February 2011 - 12:04 PM

How disappointing, I was expecting a TV, not treeview.

The treeview isn't bad though :)

#12 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,433 posts

Posted 09 February 2011 - 12:13 PM

Yashied,

That was far too easy - I am sure you knew how to do it all along! ;)

All that is needed is to utilise the $sTemplate parameter of the _GUICtrlTVExplorer_Create function.

First you need to set the default value of the parameter to something that you know cannot be matched - I suggest using ":.:" as ":" is a forbidden character within file names.
Func _GUICtrlTVExplorer_Create($sRoot, $iX, $iY, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = 0, $iFlags = -1, $sFunc = '', $sTemplate = ':.:')

Then passing no value in the parameter produces a tree showing only folders, while passing a mask will display the files which match the mask - multiple masks are separated by ";".

These lines taken from the example script have been modifed to show how you might use this:
; Display only .au3 and .ico files in the AutoIt installation folders: $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir & "\AutoIt3", 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', '*.au3;*.ico') ; set template to *.au3 and *.ico ; Display only folders - no files at all $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') ; no template parameter passed so default used = no matches ; Display all files $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', "*.*") ; template matches all files

I hope this minor addition to Yashied's excellent UDF proves useful to others. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#13 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 09 February 2011 - 12:24 PM

To get the maximum enumerating speed is better to use only $TV_FLAG_DIRTREE or other combination of $TV_FLAG_* flags, excluding $TV_FLAG_SHOWFILES. $sTemplate parameter apply only to files.

; Display only .au3 and .ico files in the AutoIt installation folders: $hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir & "\AutoIt3", 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', '*.au3;*.ico') ; set template to *.au3 and *.ico ; Display only folders - no files at all $hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, $TV_FLAG_DIRTREE, '_TVEvent') ; no template parameter passed so default used = no matches ; Display all files $hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') ; template matches all files

Edited by Yashied, 09 February 2011 - 12:33 PM.


#14 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 425 posts

Posted 20 February 2011 - 03:36 PM

Yashied,

I have a problem to implement the mode into my code application.
The handlers does not work for me.

I found in the UDF this info:

; IMPORTANT: If you register the following window messages in your code, you should call handlers from this library until ; you return from your handlers, otherwise, the TreeView Explorer will not work properly! For example: ; ; Func MY_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ;     Local $Result = TV_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ;     If $Result <> $GUI_RUNDEFMSG Then ;         Return $Result ;     EndIf ;     ... ; EndFunc


So I created the TVExplorer with the following code.

Am I doing OK?
I am prety much lost here..



_GUICtrlTVExplorer_Create(@ProgramFilesDir, 188, 160, 328, 140, -1, $WS_EX_CLIENTEDGE, -1, 'WM_NOTIFY') GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")





Plain Text         
Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)     #forceref $iMsg, $iWparam     Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu     $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)     $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))     $iCode = DllStructGetData($tNMHDR, "Code")     Switch $hWndFrom         Case $Control_2[11]             Select                 Case $iCode = $EN_MSGFILTER                     $tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)                     If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then                         $hMenu = GUICtrlGetHandle($Control_2[21])                         SetMenuTexts($hWndFrom, $hMenu)                         _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)                     EndIf             EndSelect         Case $Control_3[12]             Consolewrite("$iCode=" & $iCode &  ", $TV_NOTIFY_SELCHANGED=" & $TV_NOTIFY_SELCHANGED & @CRLF)             Select                 Case $iCode = $TV_NOTIFY_BEGINUPDATE                     GUISetCursor(1, 1)                 Case $iCode = $TV_NOTIFY_ENDUPDATE                     GUISetCursor(2)                 Case $iCode = $TV_NOTIFY_SELCHANGED                     ;For $i = 0 To 2                     ;If $Control_3[12] = $hWnd Then                     _TVSetPath($Control_3[11], $iWparam)                     ;ExitLoop                     ;EndIf                     ; Next                 Case $iCode = $TV_NOTIFY_DBLCLK                     shellexecute(_GUICtrlTVExplorer_GetSelected($Control_3[12]))                     ; Nothing                 Case $iCode = $TV_NOTIFY_RCLICK                     ; Nothing                 Case $iCode = $TV_NOTIFY_DELETINGITEM                     ; Nothing                 Case $iCode = $TV_NOTIFY_DISKMOUNTED                     ; Nothing                 Case $iCode = $TV_NOTIFY_DISKUNMOUNTED             EndSelect     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_NOTIFY

Edited by lsakizada, 20 February 2011 - 03:36 PM.

Be Green Now or Never (BGNN)!

#15 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 February 2011 - 03:50 PM

_GUICtrlTVExplorer_Create(@ProgramFilesDir, 188, 160, 328, 140, -1, $WS_EX_CLIENTEDGE, -1, 'WM_NOTIFY')

WM_NOTIFY that you specify in this function is not a Windows Message function. This is a user-defined function. Look closely at the examples. What do you exactly want to do?

#16 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 425 posts

Posted 20 February 2011 - 04:02 PM

I just want to use the UDF into my code and make the tree browsable.
I saw the example and I understood it.

Not worked for me once I set it simmilar to the example using the _TVEvent function.

The TVEvent was not called when I tried to expand the tree with the mouse.

So I went to the WM_NOTIFY function and added the handlers there.


What did you mean in yours important note?
Be Green Now or Never (BGNN)!

#17 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 February 2011 - 04:10 PM

The TVEvent was not called when I tried to expand the tree with the mouse.

When you expand a folder, TVExplorer sends two messages to the _TV_Event() function: $TV_NOTIFY_BEGINUPDATE and $TV_NOTIFY_ENDUPDATE. It works for you?

Edited by Yashied, 20 February 2011 - 04:10 PM.


#18 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 425 posts

Posted 20 February 2011 - 04:13 PM

When you expand a folder, TVExplorer sends two messages to the _TV_Event() function: $TV_NOTIFY_BEGINUPDATE and $TV_NOTIFY_ENDUPDATE. It works for you?

No , The all function was not called.

I have put debug mesage.

Plain Text         
Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)         Consolewrite("$iMsg=" & $iMsg &  @CRLF)     Switch $iMsg         Case $TV_NOTIFY_BEGINUPDATE             GUISetCursor(1, 1)         Case $TV_NOTIFY_ENDUPDATE             GUISetCursor(2)         Case $TV_NOTIFY_SELCHANGED             ;For $i = 0 To 2             If $Control_3[12] = $hWnd Then                 _TVSetPath($Control_3[11], $sPath)                 ;ExitLoop             EndIf             ; Next         Case $TV_NOTIFY_DBLCLK             ;shellexecute(_GUICtrlTVExplorer_GetSelected($hTV[0]))             ; Nothing         Case $TV_NOTIFY_RCLICK             ; Nothing         Case $TV_NOTIFY_DELETINGITEM             ; Nothing         Case $TV_NOTIFY_DISKMOUNTED             ; Nothing         Case $TV_NOTIFY_DISKUNMOUNTED             ; Nothing     EndSwitch EndFunc   ;==>_TVEvent

Edited by lsakizada, 20 February 2011 - 04:14 PM.

Be Green Now or Never (BGNN)!

#19 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 February 2011 - 04:16 PM

Please post a working example.

#20 lsakizada

lsakizada

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 425 posts

Posted 20 February 2011 - 04:51 PM

Please post a working example.


Hi, Yashied, I simmulated a simple code which somehow close to my application.

Hope I am not missing anything important to run the code..i was hurry

1) Set the TVExplore udf under include folder (WITH WINAPIEX UDF's two files)
2) The TVExplore GUI is in the second chiled application (Click next once after the load)


Plain Text         
;; Valuater #include <GuiConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiComboBox.au3> #include "include\TVExplorer.au3" Dim $show = 0, $Child_[11], $children = 10, $ChildActual = 1 Global $Control_1[10] Global $Control_2[10] Global $Control_3[10] Global $Control_4[10] Global $Control_5[10] Global $Control_6[10] Global $Control_7[10] Global $Control_8[10] Global $Control_9[10] Global $Control_10[10] Global $hFocus = 0 $Main = GUICreate("New Link Wizard", 548, 360, (@DesktopWidth - 516) / 2, (@DesktopHeight - 323) / 2, -1, -1) $Button_1 = GUICtrlCreateButton("&Next >", 20, 150, 80, 25) $Button_2 = GUICtrlCreateButton("< &Back", 20, 120, 80, 25) $Button_3 = GUICtrlCreateButton("&Exit", 20, 300, 80, 25) GUISetState() $Child_[1] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_1($Control_1) GUISetState() $Child_[2] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_2($Control_2) GUISetState(@SW_HIDE) $Child_[3] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_3($Control_3) GUISetState(@SW_HIDE) $Child_[4] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_4($Control_4) GUISetState(@SW_HIDE) $Child_[5] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_5($Control_5) GUISetState(@SW_HIDE) $Child_[6] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_6($Control_6) GUISetState(@SW_HIDE) $Child_[7] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_7($Control_7) GUISetState(@SW_HIDE) $Child_[8] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_8($Control_8) GUISetState(@SW_HIDE) $Child_[9] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_9($Control_9) GUISetState(@SW_HIDE) $Child_[10] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main) _Form_10($Control_10) GUISetState(@SW_HIDE) While 1     $msg = GUIGetMsg(1)     Switch $msg[1]         Case $Main             Switch $msg[0]                                 Case $GUI_EVENT_CLOSE                       ExitLoop                 Case $Button_3                     ExitLoop                 Case $Button_1                     Set_ChildSwitch(+1)                 Case $Button_2                     Set_ChildSwitch(-1)             EndSwitch         Case $Child_[2]             Switch $msg[0]                 Case $Control_2[0]             EndSwitch     EndSwitch WEnd GUIDelete($Main) ;--------- Functions ------------------- Func Set_ChildSwitch($ud)     GUISetState(@SW_HIDE, $Child_[$ChildActual])     $ChildActual += $ud     If $ChildActual = 11 Then $ChildActual = 1     If $ChildActual = 0 Then $ChildActual = 10     GUISetState(@SW_SHOW, $Child_[$ChildActual]) EndFunc   ;==>Set_ChildSwitch Func _Form_1(ByRef $Control_1) EndFunc   ;==>_Form_1 Func _Form_2(ByRef $Control_2)     $Control_2[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 320, 48, 200, 210, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')     $Control_2[1] = GUICtrlCreateDummy()     HotKeySet('{F5}', '_TVRefresh')     _GUICtrlTVExplorer_Expand($Control_2[0], @ProgramFilesDir & '\AutoIt3')     _GUICtrlTVExplorer_Expand($Control_2[0])     $Control_2[2] =GUICtrlCreateInput("",320,20,200,20) EndFunc   ;==>_Form_2 Func _Form_3(ByRef $Control_3) EndFunc   ;==>_Form_3 Func _Form_4(ByRef $Control_4) EndFunc   ;==>_Form_4 Func _Form_5(ByRef $Control_5) EndFunc   ;==>_Form_5 Func _Form_6(ByRef $Control_6) EndFunc   ;==>_Form_6 Func _Form_7(ByRef $Control_7) EndFunc   ;==>_Form_7 Func _Form_8(ByRef $Control_8) EndFunc   ;==>_Form_8 Func _Form_9(ByRef $Control_9) EndFunc   ;==>_Form_9 Func _Form_10(ByRef $Control_10) EndFunc   ;==>_Form_10 Func _TVSetPath($iInput, $sPath)     Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2)     If GUICtrlRead($iInput) <> $Text Then         GUICtrlSetData($iInput, $Text)     EndIf EndFunc   ;==>_TVSetPath Func _TVRefresh()     Local $hWnd = _WinAPI_GetFocus()         If $Control_2[0] = $hWnd Then             If Not $hFocus Then                 $hFocus = $hWnd                 GUICtrlSendToDummy($Control_2[1])             EndIf             Return         EndIf     HotKeySet('{F5}')     Send('{F5}')     HotKeySet('{F5}', '_TVRefresh') EndFunc   ;==>_TVRefresh Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)     Switch $iMsg         Case $TV_NOTIFY_BEGINUPDATE             GUISetCursor(1, 1)         Case $TV_NOTIFY_ENDUPDATE             GUISetCursor(2)         Case $TV_NOTIFY_SELCHANGED                 If $Control_2[0] = $hWnd Then                     _TVSetPath($Control_2[2], $sPath)                  EndIf          Case $TV_NOTIFY_DBLCLK         Case $TV_NOTIFY_RCLICK             ; Nothing         Case $TV_NOTIFY_DELETINGITEM             ; Nothing         Case $TV_NOTIFY_DISKMOUNTED             ; Nothing         Case $TV_NOTIFY_DISKUNMOUNTED             ; Nothing     EndSwitch EndFunc   ;==>_TVEvent

Be Green Now or Never (BGNN)!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users