NewForAutoit Posted April 23, 2008 Share Posted April 23, 2008 how I can colorize this item plz #include <GUIConstants.au3> Opt("TrayMenuMode", 1) $Tray = TrayCreateItem("Tray") $Show = TrayCreateItem("Show") $ExitItem = TrayCreateItem("Exit") GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Vakari Posted April 23, 2008 Share Posted April 23, 2008 There is a great example in the help file under TrayItemGetHandle(). It reads: expandcollapse popup#include <Constants.au3> Opt("TrayMenuMode", 1); Don't show the default tray context menu Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 TraySetIcon("shell32.dll", 21) TraySetToolTip("This is just a small example to show that colored tray menus" & @LF & "are easy possible under Windows 2000 and higher.") $OptionsMenu = TrayCreateMenu("Options") $OnTopItem = TrayCreateItem("Always On Top", $OptionsMenu) TrayItemSetState(-1, $TRAY_CHECKED) $RepeatItem = TrayCreateItem("Repeat Always", $OptionsMenu) TrayCreateItem("") $AboutItem = TrayCreateItem("About") TrayCreateItem("") $ExitItem = TrayCreateItem("Exit Sample") SetMenuColor(0, 0xEEBB99) ; BGR color value, '0' means the tray context menu handle itself SetMenuColor($OptionsMenu, 0x66BB99); BGR color value While 1 $Msg = TrayGetMsg() Switch $Msg Case $ExitItem ExitLoop Case $AboutItem Msgbox(64, "About...", "Colored tray menu sample") EndSwitch WEnd Exit ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) ; Minimum OS are Windows98 and 2000 If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = TrayItemGetHandle($nMenuID); Get the internal menu handle $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) EndFunc Link to comment Share on other sites More sharing options...
NewForAutoit Posted April 23, 2008 Author Share Posted April 23, 2008 (edited) thank you but not work when I put in a gui Exemple: #include <GUIConstants.au3> Opt("TrayMenuMode", 1) $Tray = TrayCreateItem("Tray") $Show = TrayCreateItem("Show") $ExitItem = TrayCreateItem("Exit") $lol = GUICreate("test item", 399, 338, 193, 125,$WS_POPUP) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited April 23, 2008 by NewForAutoit Link to comment Share on other sites More sharing options...
Vakari Posted April 23, 2008 Share Posted April 23, 2008 (edited) Give this a shot. It doesn't look pretty, and most of it is straight from the help file, but it works: #include <GUIConstants.au3> Opt("TrayMenuMode", 1) $Tray = TrayCreateItem("Tray") $Show = TrayCreateItem("Show") $ExitItem = TrayCreateItem("Exit") Global Const $MIM_APPLYTOSUBMENUS = 0x80000000 Global Const $MIM_BACKGROUND = 0x00000002 SetMenuColor(0, 0x00FF00); <- Set your color here While 1 $Msg = TrayGetMsg() Switch $Msg Case $ExitItem Exit EndSwitch WEnd Func SetMenuColor($nMenuID, $nColor) If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return $hMenu = TrayItemGetHandle($nMenuID) $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor) $hBrush = $hBrush[0] Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr") DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo)) DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND)) DllStructSetData($stMenuInfo, 5, $hBrush) DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo)) EndFunc Edited April 23, 2008 by Vakari Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now