Jump to content

Switching Controls Parent GUI


KaFu
 Share

Recommended Posts

somehow I've got the feeling it's not the most elegant and resource friendly way :mellow:. Any thoughts on this one?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>

$gui1 = GUICreate("GUI#1", 300, 400, 100, 100)
$Treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$hTreeview = GUICtrlGetHandle($Treeview)
$generalitem = GUICtrlCreateTreeViewItem("General", $Treeview)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem = GUICtrlCreateTreeViewItem("Display", $Treeview)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)

$gui2 = GUICreate("GUI#2", 300, 400, 600, 100)

WinSetTitle($gui1, "", $gui1)
WinSetTitle($gui2, "", $gui2)

GUISetState(@SW_SHOW, $gui2)
GUISetState(@SW_SHOW, $gui1)

GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY")

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()


Func MY_WM_NOTIFY($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    ConsoleWrite("WM_NOTIFY" & @TAB & $hWnd & @TAB & $msg & @TAB & $wParam & @TAB & $lParam & @TAB & $nID & @TAB & $nID & @CRLF)

    Switch WinGetHandle("[ACTIVE]", "")
        Case $gui1
            If _WinAPI_GetAncestor($hTreeview, $GA_PARENT) <> $gui1 Then
                _WinAPI_SetParent($hTreeview, $gui1)
                GUICtrlSetPos($Treeview, 0, 0, 200, 100)
            EndIf

        Case $gui2
            If _WinAPI_GetAncestor($hTreeview, $GA_PARENT) <> $gui2 Then
                _WinAPI_SetParent($hTreeview, $gui2)
                GUICtrlSetPos($Treeview, 20, 20, 200, 300)
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_NOTIFY
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...