Sign in to follow this  
Followers 0
supersonic

Place Button controls over a TreeView control

3 posts in this topic

#1 ·  Posted (edited)

Hi everyone,

I'm trying to place Button controls over a TreeView control.

With this Buttons I would like to collapse/expand the TreeView.

Here's the sample code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUITreeView.au3>
#include <WindowsConstants.au3>

Local $hGUI         =   GUICreate("", 800, 600, -1, -1, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU))
Local $hGUI_TV0     =   GUICtrlCreateTreeView(25, 102, 350, 456, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $hGUI_B1      =   GUICtrlCreateButton("", 330, 100, 18, 18, $BS_ICON)
Local $hGUI_B2      =   GUICtrlCreateButton("", 350, 100, 18, 18, $BS_ICON)

GUICtrlCreateTreeViewItem("TEST", $hGUI_TV0)
GUICtrlSetState($hGUI_B1, $GUI_ONTOP)
GUICtrlSetState($hGUI_B2, $GUI_ONTOP)
GUISetState(@SW_SHOW, $hGUI)

While 1
    Local $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
            EndSwitch
    EndSwitch
    Sleep(10)
WEnd

GUIDelete($hGUI)

How to avoid the Button controls hiding behind the TreeView control?

Greets,

-supersonic.

Edited by supersonic

Share this post


Link to post
Share on other sites



supersonic,

You use the $WS_EX_TOPMOST extened style, but (and it is a big but).........

You will not be able to place the button on top of the TreeView as AutoIt gets confused when you overlap 2 controls. As it cannot decide which you want to action, it refuses to action either in the overlap area. ;)

Look at this slightly modified version of your script where I have moved the left button: :alien:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUITreeView.au3>
#include <WindowsConstants.au3>

Local $hGUI         =   GUICreate("", 800, 600, -1, -1, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU))
Local $hGUI_TV0     =   GUICtrlCreateTreeView(25, 102, 350, 456, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $hGUI_B1      =   GUICtrlCreateButton("", 330, 95, 18, 18, $BS_ICON, $WS_EX_TOPMOST) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Local $hGUI_B2      =   GUICtrlCreateButton("", 350, 100, 18, 18, $BS_ICON, $WS_EX_TOPMOST)

GUICtrlCreateTreeViewItem("TEST", $hGUI_TV0)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Local $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $hGUI_B1
                    MsgBox(0, "Pressed", "I am working")
            EndSwitch
    EndSwitch
    ; Sleep(10) - not needed when you use GUIGetMsg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
WEnd

GUIDelete($hGUI)

Try and action the left button by pressing on the lower part within the TreeView - you will not get the MsgBox. It will only appear if you press on the part of the button outside the TreeView.

All clear? :huh2:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba,

thank you for your reply.

I tried $WS_EX_TOPMOST, etc. already before...

With the very same result... :huh2:

But this is not a real problem;

I just thought this would look nice...

Greets,

-supersonic.

Share this post


Link to post
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
Sign in to follow this  
Followers 0