Popular Post LarsJ Posted February 12, 2023 Popular Post Share Posted February 12, 2023 (edited) TreeView Extended Styles The MS docu for TreeView extended styles can be found here. Most styles revolve around visual features. This is an implementation of some of these styles: TVS_EX_AUTOHSCROLL Failed to get this style to work. May depend on the TVM_SETAUTOSCROLLINFO message. TVS_EX_DIMMEDCHECKBOXES, TVS_EX_EXCLUSIONCHECKBOXES, TVS_EX_PARTIALCHECKBOXES Depends on the TVS_CHECKBOXES style also being set. The extended CheckBoxes styles must be set before the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. These CheckBoxes look better on Windows 7 than on Windows 10. On Windows 10, some of the state images become very similar. Maybe it's possible to save the state images as icons on Windows 7 and load the icons as new state images on Windows 10. Not tested. TVS_EX_DOUBLEBUFFER The double buffer extended style is usually used to reduce flicker when using the vertical ScrollBar. Therefore, the style is interesting compared to virtual TreeViews. However, it's somewhat uncertain whether the style has any effect at all for these TreeViews, or whether it only works for standard TreeViews. TVS_EX_DRAWIMAGEASYNC Has not been implemented so far. TVS_EX_FADEINOUTEXPANDOS Fade in/out of collapse/expand Buttons when the TreeView control gains/loses focus. Also works better on Windows 7 than on Windows 10. TVS_EX_MULTISELECT According to MS docu this style is not supported. Not implemented. TVS_EX_NOINDENTSTATE No indentation of collapse/expand Buttons. Thus, these Buttons are aligned along the left edge of the TreeView. Failed to get this style to work. TVS_EX_NOSINGLECOLLAPSE Intended for internal use. Not implemented. TVS_EX_RICHTOOLTIP Seems to depend on custom drawn ToolTips. Not implemented. TreeViewExtendedStyles.au3 include #include-once #include <SendMessage.au3> #include <TreeViewConstants.au3> Global Const $TVS_EX_MULTISELECT = 0x0002 Global Const $TVS_EX_DOUBLEBUFFER = 0x0004 Global Const $TVS_EX_NOINDENTSTATE = 0x0008 Global Const $TVS_EX_RICHTOOLTIP = 0x0010 Global Const $TVS_EX_AUTOHSCROLL = 0x0020 Global Const $TVS_EX_FADEINOUTEXPANDOS = 0x0040 Global Const $TVS_EX_PARTIALCHECKBOXES = 0x0080 Global Const $TVS_EX_EXCLUSIONCHECKBOXES = 0x0100 Global Const $TVS_EX_DIMMEDCHECKBOXES = 0x0200 Global Const $TVS_EX_DRAWIMAGEASYNC = 0x0400 Global Const $TVM_SETEXTENDEDSTYLE = $TV_FIRST + 44 Global Const $TVM_GETEXTENDEDSTYLE = $TV_FIRST + 45 Func _GUICtrlTreeView_GetExtendedStyle( $hWnd ) Return IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_GETEXTENDEDSTYLE ) _ : GUICtrlSendMsg( $hWnd, $TVM_GETEXTENDEDSTYLE, 0, 0 ) EndFunc ; $iExStyle: Extended control styles ; $iExMask: Specifies which styles in $iExStyle are to be affected Func _GUICtrlTreeView_SetExtendedStyle( $hWnd, $iExStyle, $iExMask = 0 ) Local $iRet = IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _ : GUICtrlSendMsg( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _WinAPI_InvalidateRect( $hWnd ) Return $iRet EndFunc CheckBoxes.au3 example Examples in the Examples\Styles\ folder. Run the examples in SciTE with F5. This is the extended CheckBoxes example, CheckBoxes.au3: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" #include "..\..\Includes\TreeViewExtendedStyles.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - CheckBoxes", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set CheckBoxes extended styles ; Click CheckBoxes several times to see the different styles _GUICtrlTreeView_SetExtendedStyle( $idTV, $TVS_EX_PARTIALCHECKBOXES+$TVS_EX_EXCLUSIONCHECKBOXES+$TVS_EX_DIMMEDCHECKBOXES ) ; Set CheckBoxes style ; Must be set AFTER extended styles ; Extended CheckBox styles depends on the TVS_CHECKBOXES style also being set. The extended CheckBox styles ; must be set BEFORE the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE )[0] + $TVS_CHECKBOXES ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The image shows the 5 CheckBoxes on Windows 7 with state image indices 1 - 5: TreeView Explorer Theme Example in the Examples\Theme\ folder. Run the example in SciTE with F5. ExplorerTheme.au3: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <WinAPITheme.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - ExplorerTheme", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set Explorer theme _WinAPI_SetWindowTheme( $hTV, "Explorer", 0 ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The Explorer theme on Windows 7. Looks better on Windows 10. 7z-file The 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. TreeViewStyles.7z Edited February 12, 2023 by LarsJ Zedna, argumentum, AutoBert and 3 others 4 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
kut0 Posted February 16, 2023 Share Posted February 16, 2023 Thank you very much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now