| 1 | |
|---|
| 2 | #include <GuiToolbar.au3> |
|---|
| 3 | #include <GuiConstantsEx.au3> |
|---|
| 4 | #include <WindowsConstants.au3> |
|---|
| 5 | #include <Constants.au3> |
|---|
| 6 | |
|---|
| 7 | Opt('MustDeclareVars', 1) |
|---|
| 8 | |
|---|
| 9 | $Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work |
|---|
| 10 | |
|---|
| 11 | Global $hToolbar, $iMemo |
|---|
| 12 | Global $iItem ; Command identifier of the button associated with the notification. |
|---|
| 13 | Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp |
|---|
| 14 | |
|---|
| 15 | _Main() |
|---|
| 16 | |
|---|
| 17 | Func _Main() |
|---|
| 18 | Local $hGUI, $aSize |
|---|
| 19 | |
|---|
| 20 | ; Create GUI |
|---|
| 21 | $hGUI = GUICreate("Toolbar", 600, 400) |
|---|
| 22 | $hToolbar = _GUICtrlToolbar_Create ($hGUI) |
|---|
| 23 | $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar) |
|---|
| 24 | |
|---|
| 25 | $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL) |
|---|
| 26 | GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") |
|---|
| 27 | GUISetState() |
|---|
| 28 | GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") |
|---|
| 29 | |
|---|
| 30 | ; Add standard system bitmaps |
|---|
| 31 | _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) |
|---|
| 32 | |
|---|
| 33 | ; Add buttons |
|---|
| 34 | _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW) |
|---|
| 35 | _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN) |
|---|
| 36 | _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE) |
|---|
| 37 | _GUICtrlToolbar_AddButtonSep ($hToolbar) |
|---|
| 38 | _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP) |
|---|
| 39 | |
|---|
| 40 | ; Loop until user exits |
|---|
| 41 | Do |
|---|
| 42 | Until GUIGetMsg() = $GUI_EVENT_CLOSE |
|---|
| 43 | |
|---|
| 44 | EndFunc ;==>_Main |
|---|
| 45 | |
|---|
| 46 | ; Write message to memo |
|---|
| 47 | Func MemoWrite($sMessage = "") |
|---|
| 48 | GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) |
|---|
| 49 | EndFunc ;==>MemoWrite |
|---|
| 50 | |
|---|
| 51 | ; WM_NOTIFY event handler |
|---|
| 52 | Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) |
|---|
| 53 | #forceref $hWndGUI, $MsgID, $wParam |
|---|
| 54 | Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld |
|---|
| 55 | Local $tNMTOOLBAR, $tNMTBHOTITEM |
|---|
| 56 | $tNMHDR = DllStructCreate($tagNMHDR, $lParam) |
|---|
| 57 | $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") |
|---|
| 58 | $idFrom = DllStructGetData($tNMHDR, "IDFrom") |
|---|
| 59 | $code = DllStructGetData($tNMHDR, "Code") |
|---|
| 60 | Switch $hwndFrom |
|---|
| 61 | Case $hToolbar |
|---|
| 62 | Switch $code |
|---|
| 63 | Case $NM_LDOWN |
|---|
| 64 | ;---------------------------------------------------------------------------------------------- |
|---|
| 65 | MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem)) |
|---|
| 66 | ;---------------------------------------------------------------------------------------------- |
|---|
| 67 | Case $TBN_HOTITEMCHANGE |
|---|
| 68 | $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) |
|---|
| 69 | $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld") |
|---|
| 70 | $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew") |
|---|
| 71 | $iItem = $i_idNew |
|---|
| 72 | $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") |
|---|
| 73 | |
|---|
| 74 | EndSwitch |
|---|
| 75 | EndSwitch |
|---|
| 76 | Return $GUI_RUNDEFMSG |
|---|
| 77 | EndFunc ;==>_WM_NOTIFY |
|---|
| 78 | |
|---|