1 | #include <GuiToolbar.au3> |
---|
2 | #include <GUIConstantsEx.au3> |
---|
3 | #include <WindowsConstants.au3> |
---|
4 | |
---|
5 | Global $hToolbar, $iMemo |
---|
6 | Global $iItem ; Command identifier of the button associated with the notification. |
---|
7 | Global Enum $id_New = 1000, $id_Open, $id_Save, $id_Help |
---|
8 | |
---|
9 | Example() |
---|
10 | |
---|
11 | Func Example() |
---|
12 | Local $hGUI, $aSize |
---|
13 | |
---|
14 | ; Create GUI |
---|
15 | $hGUI = GUICreate("Toolbar", 600, 400) |
---|
16 | $hToolbar = _GUICtrlToolbar_Create($hGUI) |
---|
17 | $aSize = _GUICtrlToolbar_GetMaxSize($hToolbar) |
---|
18 | |
---|
19 | $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL) |
---|
20 | GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") |
---|
21 | GUISetState() |
---|
22 | GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") |
---|
23 | |
---|
24 | ; Add standard system bitmaps |
---|
25 | _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) |
---|
26 | |
---|
27 | ; Add buttons |
---|
28 | _GUICtrlToolbar_AddButton($hToolbar, $id_New, $STD_FILENEW) |
---|
29 | _GUICtrlToolbar_AddButton($hToolbar, $id_Open, $STD_FILEOPEN) |
---|
30 | _GUICtrlToolbar_AddButton($hToolbar, $id_Save, $STD_FILESAVE) |
---|
31 | _GUICtrlToolbar_AddButtonSep($hToolbar) |
---|
32 | _GUICtrlToolbar_AddButton($hToolbar, $id_Help, $STD_HELP) |
---|
33 | |
---|
34 | ; Sets the hot item |
---|
35 | _GUICtrlToolbar_SetHotItem($hToolbar, 2) |
---|
36 | |
---|
37 | ; Loop until user exits |
---|
38 | Do |
---|
39 | Until GUIGetMsg() = $GUI_EVENT_CLOSE |
---|
40 | EndFunc ;==>Example |
---|
41 | |
---|
42 | ; Write message to memo |
---|
43 | Func MemoWrite($sMessage = "") |
---|
44 | GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) |
---|
45 | EndFunc ;==>MemoWrite |
---|
46 | |
---|
47 | ; WM_NOTIFY event handler |
---|
48 | Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) |
---|
49 | #forceref $hWndGUI, $MsgID, $wParam |
---|
50 | Local $tNMHDR, $hwndFrom, $code, $i_idNew, $dwFlags, $i_idOld |
---|
51 | Local $tNMTBHOTITEM |
---|
52 | $tNMHDR = DllStructCreate($tagNMHDR, $lParam) |
---|
53 | $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") |
---|
54 | $code = DllStructGetData($tNMHDR, "Code") |
---|
55 | Switch $hwndFrom |
---|
56 | Case $hToolbar |
---|
57 | Switch $code |
---|
58 | Case $NM_LDOWN |
---|
59 | ;---------------------------------------------------------------------------------------------- |
---|
60 | MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($hToolbar, $iItem)) |
---|
61 | ;---------------------------------------------------------------------------------------------- |
---|
62 | Case $TBN_HOTITEMCHANGE |
---|
63 | $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) |
---|
64 | $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld") |
---|
65 | $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew") |
---|
66 | $iItem = $i_idNew |
---|
67 | $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") |
---|
68 | If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then |
---|
69 | MemoWrite("$HICF_LEAVING: " & $i_idOld) |
---|
70 | Else |
---|
71 | Switch $i_idNew |
---|
72 | Case $id_New |
---|
73 | ;---------------------------------------------------------------------------------------------- |
---|
74 | MemoWrite("$TBN_HOTITEMCHANGE: $idNew") |
---|
75 | ;---------------------------------------------------------------------------------------------- |
---|
76 | Case $id_Open |
---|
77 | ;---------------------------------------------------------------------------------------------- |
---|
78 | MemoWrite("$TBN_HOTITEMCHANGE: $idOpen") |
---|
79 | ;---------------------------------------------------------------------------------------------- |
---|
80 | Case $id_Save |
---|
81 | ;---------------------------------------------------------------------------------------------- |
---|
82 | MemoWrite("$TBN_HOTITEMCHANGE: $idSave") |
---|
83 | ;---------------------------------------------------------------------------------------------- |
---|
84 | Case $id_Help |
---|
85 | ;---------------------------------------------------------------------------------------------- |
---|
86 | MemoWrite("$TBN_HOTITEMCHANGE: $idHelp") |
---|
87 | ;---------------------------------------------------------------------------------------------- |
---|
88 | EndSwitch |
---|
89 | EndIf |
---|
90 | EndSwitch |
---|
91 | EndSwitch |
---|
92 | Return $GUI_RUNDEFMSG |
---|
93 | EndFunc ;==>_WM_NOTIFY |
---|