Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GuiToolbar.au3>
- #include <GuiImageList.au3>
- #include <GuiConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <GDIPlus.au3>
- Global $iItem
- Global $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
- Global Enum $but1 = 1000, $but2, $but3, $but4
- ; Создание GUI
- $hGUI = GUICreate("Toolbar", 400, 300)
- $hToolbar = _GUICtrlToolbar_Create($hGUI)
- GUISetState()
- GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
- $CloseBMP = _ImgProcess(Binary("0x89504E470D0A1A0A0000000D49484452000000100000000F0806000000ED734F2F000000097048597300000B1300000B1301009A9C180000008049444154785E9D93610A80200C85F7C2837934BBD93CD98B09239865CD0F4A067BDFDC0F41B981086501AD255024403E3B00589A517248029243B22D0030AD5A12D383C86FB0CFBE80E4F8FD5AA1F72E6F686BFC75835A6BAC732BA8AA87ECB43A0812120F67051EB6732D00E0DF1436A2A47C3C167AC88935286BCED6962D1714C53BA791E5B88A0000000049454E44AE426082"))
- $CloseBMP2 = _ImgProcess(Binary("0x89504E470D0A1A0A0000000D49484452000000100000000F0806000000ED734F2F0000006F4944415478DA63644005FF19F003464202FF8100BB4E4646AC7A48320024073588912C03B0B99E6803B0183680062019C448D8802A1F9C0634B29B12E102A0018CED5B19FE577A236C86F28936005913B2612419806C08C95E20C90568A6911C0698CE2131163040434303DE840100CC5460089F51B34E0000000049454E44AE426082"))
- ; Список иконок для нормальных кнопок
- $hNormal = _GUIImageList_Create(16,16, 5)
- _GUIImageList_AddIcon($hNormal, 'shell32.dll', 3)
- _GUIImageList_AddIcon($hNormal, 'regedit.exe', 0)
- _GUIImageList_AddIcon($hNormal, 'notepad.exe', 0)
- _GUIImageList_Add($hNormal, $CloseBMP)
- _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)
- ; Список иконок для отключенных кнопок
- $hDisabled = _GUIImageList_Create(16,16, 5)
- _GUIImageList_AddIcon($hDisabled, 'shell32.dll', 7)
- _GUIImageList_AddIcon($hDisabled, 'shell32.dll', 8)
- _GUIImageList_AddIcon($hDisabled, 'shell32.dll', 12)
- _GUIImageList_Add($hDisabled, $CloseBMP2)
- _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)
- ; Список иконок для состояния наведения на кнопку
- $hHot = _GUIImageList_Create(16,16, 5)
- _GUIImageList_AddIcon($hHot, 'shell32.dll', 4)
- _GUIImageList_AddIcon($hHot, 'shell32.dll', 12)
- _GUIImageList_AddIcon($hHot, 'shell32.dll', 3)
- _GUIImageList_Add($hHot, $CloseBMP2)
- _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)
- ; Добавление кнопок
- _GUICtrlToolbar_AddButton($hToolbar, $but1, 0)
- _GUICtrlToolbar_AddButton($hToolbar, $but2, 1)
- _GUICtrlToolbar_AddButton($hToolbar, $but3, 2)
- _GUICtrlToolbar_AddButton($hToolbar, $but4, 3)
- ; Disable Blue button
- ; _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)
- Do
- Until GUIGetMsg() = $GUI_EVENT_CLOSE
- Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
- #forceref $hWndGUI, $MsgID, $wParam
- Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
- Local $tNMTOOLBAR, $tNMTBHOTITEM
- $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
- $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
- $idFrom = DllStructGetData($tNMHDR, "IDFrom")
- $code = DllStructGetData($tNMHDR, "Code")
- Switch $hwndFrom
- Case $hToolbar
- Switch $code
- Case $NM_LDOWN
- $a = _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem)
- Switch $iItem
- Case $but1
- Run('Explorer.exe')
- Case $but2
- Run('regedit.exe')
- Case $but3
- Run('notepad.exe')
- Case $but4
- Exit
- EndSwitch
- Case $TBN_HOTITEMCHANGE
- $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
- $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
- $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
- $iItem = $i_idNew
- $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
- If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
- ; SoundPlay(@WindowsDir & "\media\start.wav")
- Else
- Switch $i_idNew
- Case $but1, $but2, $but3, $but4
- SoundPlay(@WindowsDir & "\media\start.wav")
- EndSwitch
- EndIf
- EndSwitch
- EndSwitch
- Return $GUI_RUNDEFMSG
- EndFunc ;==>_WM_NOTIFY
- Func _ImgProcess(Const $bBinary);Merged code by Progandy and Zedna
- Local $iLen = BinaryLen($bBinary)
- If $iLen = 0 Then Return SetError(2, 0, 0)
- Local $hMem = _MemGlobalAlloc($iLen, $GMEM_MOVEABLE)
- If @error Or Not $hMem Then Return SetError(3, 0, 0)
- DllStructSetData(DllStructCreate("byte[" & $iLen & "]", _MemGlobalLock($hMem)), 1, $bBinary)
- If @error Then
- _MemGlobalUnlock($hMem)
- _MemGlobalFree($hMem)
- Return SetError(4, 0, 0)
- EndIf
- _MemGlobalUnlock($hMem)
- _GDIPlus_Startup()
- Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hMem, "bool", True, "ptr*", 0)
- If @error Or $aResult[0] <> 0 Or $aResult[3] = 0 Then Return SetError(5, @error, 0)
- Local $hImage = DllCall($ghGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $aResult[3], "int*", 0)
- Local $error = @error
- Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
- DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $aResult[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
- If @error Then Return SetError(6, $error, 0)
- If $hImage[2] = 0 Then Return SetError(7, 0, $hImage[2])
- Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage[2])
- _GDIPlus_ImageDispose($hImage[2])
- _GDIPlus_Shutdown()
- Return SetError(0, 0, $hBitmap)
- EndFunc ;==>_ImgProcess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement