Ticket #222: GUIRegisterMsg_Regression_Part2.au3

File GUIRegisterMsg_Regression_Part2.au3, 2.3 KB (added by Ultima, 13 years ago)

(2008-05-08)

Line 
1#Include <GUIConstantsEx.au3>
2#Include <TreeViewConstants.au3>
3#Include <WindowsConstants.au3>
4#Include <StructureConstants.au3>
5
6Opt("GUICloseOnESC",  0)
7Opt("GUIOnEventMode", 1)
8
9; MAIN GUI ---------------------------------------------------------------------
10Global $GUIMain_iWidth  = 300
11Global $GUIMain_iHeight = 200
12
13Global $GUIMain = GUICreate(@AutoItVersion, $GUIMain_iWidth, $GUIMain_iHeight)
14GUISetOnEvent($GUI_EVENT_CLOSE, "mainExit", $GUIMain)
15GUISetState(@SW_SHOW, $GUIMain)
16
17Global $GUIMain_TreeView = GUICtrlCreateTreeView(5, 5, $GUIMain_iWidth - 10, $GUIMain_iHeight - 10, $TVS_HASBUTTONS + $TVS_HASLINES + $TVS_LINESATROOT + $TVS_DISABLEDRAGDROP + $TVS_SHOWSELALWAYS + $TVS_NONEVENHEIGHT, $WS_EX_CLIENTEDGE)
18Global $GUIMain_TreeView_hWnd = GUICtrlGetHandle($GUIMain_TreeView)
19GUICtrlCreateTreeViewItem("SUBKEY", GUICtrlCreateTreeViewItem("ROOT", $GUIMain_TreeView))
20
21; CHILD GUI --------------------------------------------------------------------
22Global $GUIChild_iWidth  = 150
23Global $GUIChild_iHeight = 75
24
25Global $GUIChild = GUICreate("Child", $GUIChild_iWidth, $GUIChild_iHeight, Default, Default, $WS_OVERLAPPEDWINDOW, Default, $GUIMain)
26GUISetOnEvent($GUI_EVENT_CLOSE, "childHide", $GUIChild)
27
28; EVENT FUNCTIONS --------------------------------------------------------------
29Func childHide()
30        GUISetState(@SW_HIDE, $GUIChild)
31EndFunc
32
33Func childShow()
34        WinMove($GUIChild, "", Default, Default)
35        GUISetState(@SW_SHOW, $GUIChild)
36EndFunc
37
38Func mainExit()
39        Exit
40EndFunc
41
42; WM_NOTIFY HANDLER ------------------------------------------------------------
43GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
44
45Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
46        Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
47
48        Switch DllStructGetData($tNMHDR, "hWndFrom")
49                Case $GUIMain_TreeView_hWnd
50                        Switch DllStructGetData($tNMHDR, "Code")
51                                Case $NM_DBLCLK
52                                        Return 1 + childShow()
53                        EndSwitch
54        EndSwitch
55
56        Return $GUI_RUNDEFMSG
57EndFunc
58
59; WM_GETMINMAXINFO HANDLER -----------------------------------------------------
60GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
61
62Func WM_GETMINMAXINFO($hWnd, $vMsg, $wParam, $lParam)
63        Return $GUI_RUNDEFMSG
64EndFunc
65
66; MAIN LOOP --------------------------------------------------------------------
67While 1
68        Sleep(1000)
69WEnd