KaFu Posted July 24, 2009 Posted July 24, 2009 _GUICtrlMenu_SetMenuBackground() is used to set background color. Anyone knows how to set the highlight color used when you hover over a menu entry? Cheers OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
BugFix Posted July 24, 2009 Posted July 24, 2009 You can do it by set general system settings: #Include <WinAPI.au3> #include <WindowsConstants.au3> ; $COLOR_HIGHLIGHT - Item(s) selected in a control. ; $COLOR_HIGHLIGHTTEXT - Text of item(s) selected in a control. Local $aElements[2] = [$COLOR_HIGHLIGHT,$COLOR_HIGHLIGHTTEXT] Local $aOldColor[2] = [_WinAPI_GetSysColor($COLOR_HIGHLIGHT),_WinAPI_GetSysColor($COLOR_HIGHLIGHTTEXT)] Local $aNewColor[2] = [0x008000,0x00D7FF] _WinAPI_SetSysColors($aElements, $aNewColor) GUICreate('test', 130, 100) GUICtrlCreateLabel('HighLight color changed.', 5, 40) GUISetState() Do Until GUIGetMsg() = -3 _WinAPI_SetSysColors($aElements, $aOldColor) Best Regards BugFix
KaFu Posted July 27, 2009 Author Posted July 27, 2009 (edited) Thanks for the feedback! In general this is exactly what I was looking for. For menus the highlight color is $COLOR_MENUHILIGHT. Sadly this setting is system-wide. Is there a possibility to restrict this behaviour to my own GUI only? expandcollapse popup#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; $COLOR_HIGHLIGHT - Item(s) selected in a control. ; $COLOR_HIGHLIGHTTEXT - Text of item(s) selected in a control. Local $aElements[2] = [$COLOR_HIGHLIGHTTEXT,$COLOR_MENUHILIGHT] Local $aOldColor[2] = [_WinAPI_GetSysColor($COLOR_HIGHLIGHTTEXT),_WinAPI_GetSysColor($COLOR_MENUHILIGHT)] Local $aNewColor[2] = [0x0000FF, 0xC2EEFF] _WinAPI_SetSysColors($aElements, $aNewColor) Opt('MustDeclareVars', 1) Global $iMemo Global Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout _Main() _WinAPI_SetSysColors($aElements, $aOldColor) Func _Main() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hFile, 0, "&New", $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, "&Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hFile, 2, "&Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hFile, 4, "E&xit", $idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hEdit, 0, "&Cut", $idCut) _GUICtrlMenu_InsertMenuItem ($hEdit, 1, "C&opy", $idCopy) _GUICtrlMenu_InsertMenuItem ($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem ($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) ; Create memo control $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Loop until user exits GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Handle menu commands Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch _WinAPI_LoWord ($iwParam) Case $idNew MemoWrite("New") Case $idOpen MemoWrite("Open") Case $idSave MemoWrite("Save") Case $idExit Exit Case $idCut MemoWrite("Cut") Case $idCopy MemoWrite("Copy") Case $idPaste MemoWrite("Paste") Case $idAbout MemoWrite("About") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited July 27, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
BugFix Posted July 27, 2009 Posted July 27, 2009 A workaround may be, to toggle this settings by check which window is active: yours or another one. Best Regards BugFix
KaFu Posted July 27, 2009 Author Posted July 27, 2009 A workaround may be, to toggle this settings by check which window is active: yours or another one.Thought about this one too, until I saw the language selector in my taskbar changing colors >_<... would prefer a 'permanent' solution. Already searched msdn in vain, maybe I'll do some more googling this evening , thanks for your feedback! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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