nend Posted December 2, 2009 Share Posted December 2, 2009 I found this in the help file (to set colour to the traymenu). It works perfect but I want it on the fly (without shutting down te programm) to set it back to normal. Is there a way to do that? 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) $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...
Moderators Melba23 Posted December 2, 2009 Moderators Share Posted December 2, 2009 nend,Just reset the colours to the original, which you can find using _WinAPI_GetSysColor:expandcollapse popup#include <Constants.au3> #include <WindowsConstants.au3> #Include <WinAPI.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("") $ResetItem = TrayCreateItem("Reset") TrayCreateItem("") $ExitItem = TrayCreateItem("Exit Sample") $iOrg_MenuColour = _WinAPI_GetSysColor($COLOR_MENU) 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") Case $ResetItem SetMenuColor(0, $iOrg_MenuColour) SetMenuColor($OptionsMenu, $iOrg_MenuColour) EndSwitch WEnd Exit ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) $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)) EndFuncM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nend Posted December 2, 2009 Author Share Posted December 2, 2009 Yep!! that's wat I'm looking for, Thanks for the help. nend, Just reset the colours to the original, which you can find using _WinAPI_GetSysColor: expandcollapse popup#include <Constants.au3> #include <WindowsConstants.au3> #Include <WinAPI.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("") $ResetItem = TrayCreateItem("Reset") TrayCreateItem("") $ExitItem = TrayCreateItem("Exit Sample") $iOrg_MenuColour = _WinAPI_GetSysColor($COLOR_MENU) 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") Case $ResetItem SetMenuColor(0, $iOrg_MenuColour) SetMenuColor($OptionsMenu, $iOrg_MenuColour) EndSwitch WEnd Exit ; Apply the color to the menu Func SetMenuColor($nMenuID, $nColor) $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 M23 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