Jump to content

Recommended Posts

Posted

So I've been trying to get my tree view control to resize properly, and it does everything but dock to the bottom of the GUI. It works fine when I use it on a GUICtrlCreateTreeView control, but stops working when I use _GUICtrlTreeView_Create. Unfortunately, TVN_SELCHANGED doesn't work with GUICtrlCreateTreeView or else I would use it. Any ideas?

#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

AutoItSetOption("MustDeclareVars", 1)

Global $iWidth = 538, $iHeight = 522, $hMainGUI, $lvUsers, $tvRegistry, $tviRoot, $lvRegistry
Global $nMsg, $aPos

#Region ### START Koda GUI section ### Form=
$hMainGUI = GUICreate("MHRT", $iWidth, $iHeight, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUICtrlCreateGroup(" Profiles ", 8, 8, $iWidth - 16, 113)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT, $GUI_DOCKTOP))
$lvUsers = GUICtrlCreateListView("Name|SID|Profile|RefCount", 16, 24, $iWidth - 32, 86)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT, $GUI_DOCKTOP))
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Registry ", 8, 128, $iWidth - 16, $iHeight - 136)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
$tvRegistry = _GUICtrlTreeView_Create($hMainGUI, 16, 144, 153, $iHeight - 161, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
$tviRoot = _GUICtrlTreeView_Add($tvRegistry, 0, "\")
$lvRegistry = GUICtrlCreateListView("Name|Type|Data", 176, 144, $iWidth - 192, $iHeight - 161)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Posted

#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

AutoItSetOption("MustDeclareVars", 1)

Global $iWidth = 538, $iHeight = 522, $hMainGUI, $lvUsers, $tvRegistry, $tviRoot, $lvRegistry
Global $nMsg, $aPos
Global $hTreeView

GUIRegisterMsg($WM_NOTIFY, 'OnNotify')

#Region ### START Koda GUI section ### Form=
$hMainGUI = GUICreate("MHRT", $iWidth, $iHeight, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUICtrlCreateGroup(" Profiles ", 8, 8, $iWidth - 16, 113)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT, $GUI_DOCKTOP))
$lvUsers = GUICtrlCreateListView("Name|SID|Profile|RefCount", 16, 24, $iWidth - 32, 86)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKHEIGHT, $GUI_DOCKTOP))
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Registry ", 8, 128, $iWidth - 16, $iHeight - 136)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
$tvRegistry = GUICtrlCreateTreeView(16, 144, 153, $iHeight - 161, -1, $WS_EX_CLIENTEDGE)
$hTreeView = GUICtrlGetHandle(-1)

GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKWIDTH, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
$tviRoot = _GUICtrlTreeView_Add($tvRegistry, 0, "\")
$lvRegistry = GUICtrlCreateListView("Name|Type|Data", 176, 144, $iWidth - 192, $iHeight - 161)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKLEFT, $GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKTOP))
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func OnNotify($hwnd, $iMsg, $iwParam, $ilParam)
    Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam)
    Local $hItem
    
    If DllStructGetData($tNMTREEVIEW, 'hWndFrom') = $hTreeView Then
        Switch DllStructGetData($tNMTREEVIEW, 'Code')
            Case $TVN_SELCHANGED, $TVN_SELCHANGEDW
                $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
                ConsoleWrite(_GUICtrlTreeView_GetText($hTreeView, $hItem) & @LF)
        EndSwitch
    EndIf
    
    Return $GUI_RUNDEFMSG
EndFunc

Posted

Also, I just noticed the _GUICtrlTreeView_SetUnicodeFormat function. If you set it to False (ANSI), then the GUICreateTreeView control will correctly receive TVN_SELCHANGED notifications.

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
×
×
  • Create New...