GaryFrost Posted January 26, 2008 Posted January 26, 2008 Hi Yeah, Greenhorn you're rigth.. @Gary: (Sorry, i now, you are not a color^^) Yes, the inMenu is colored, like this: http://www.autoitscript.com/forum/index.ph...;hl=color++menu But the Gray (not you^^) Top Menu isnt colored I have already installed the Beta. (3.2.11.0) Thank you for Replies Mfg / BEst regards sPider expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiMenu.au3> Global Const $COLOR_ACTIVECAPTION = 2 Global Const $COLOR_GRADIENTACTIVECAPTION = 27 _Main() Func _Main() Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION] ; Red and Yellow Local $aColors[2] = [255, 65535], $aSaveColors[2] $hGui = GUICreate("My GUI", 300, 200) $FileMenu = GUICtrlCreateMenu("&File") $OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) $EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) ; Minimum OS are Windows98 and 2000 If @OSVersion <> "WIN_95" And @OSVersion <> "WIN_NT4" Then _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($FileMenu), _WinAPI_CreateSolidBrush(0xEEBB99)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($OptionsMenu), _WinAPI_CreateSolidBrush(0x66BB99)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($HelpMenu), _WinAPI_CreateSolidBrush(0x99BBEE)) $hmenu = _GUICtrlMenu_GetMenu($hGui) _GUICtrlMenu_SetMenuBackground($hmenu, _WinAPI_CreateSolidBrush(65280)) EndIf $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION) $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION) _WinAPI_SetSysColors($aElements, $aColors) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $EndBtn, $GUI_EVENT_CLOSE ExitLoop Case $AboutItem MsgBox(64, "About...", "Colored menu sample") EndSwitch WEnd GUIDelete() _WinAPI_SetSysColors($aElements, $aSaveColors) Exit EndFunc ;==>_Main Func _WinAPI_SetSysColors($vElements, $vColors) Local $isEArray = IsArray($vElements), $isCArray = IsArray($vColors) Local $iElementNum If Not $isCArray And Not $isEArray Then $iElementNum = 1 ElseIf $isCArray Or $isEArray Then If Not $isCArray Or Not $isEArray Then Return SetError(-1, -1, False) If UBound($vElements) <> UBound($vColors) Then Return SetError(-1, -1, False) $iElementNum = UBound($vElements) EndIf Local $tElements = DllStructCreate("int Element[" & $iElementNum & "]") Local $tColors = DllStructCreate("int NewColor[" & $iElementNum & "]") Local $pElements = DllStructGetPtr($tElements) Local $pColors = DllStructGetPtr($tColors) If Not $isEArray Then DllStructSetData($tElements, "Element", $vElements, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tElements, "Element", $vElements[$x], $x + 1) Next EndIf If Not $isCArray Then DllStructSetData($tColors, "NewColor", $vColors, 1) Else For $x = 0 To $iElementNum - 1 DllStructSetData($tColors, "NewColor", $vColors[$x], $x + 1) Next EndIf Local $iResults = DllCall("user32.dll", "int", "SetSysColors", "int", $iElementNum, "ptr", $pElements, "ptr", $pColors) If @error Then Return SetError(-1, -1, False) Return $iResults[0] <> 0 EndFunc ;==>_WinAPI_SetSysColors SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GtaSpider Posted January 26, 2008 Author Posted January 26, 2008 Hi Gary, you are my GOD!! Thank you very much, you are amazing! But now i've an other Problem.. I'll change the Position and width of the Menu. No Problem, with $WS_POPUP and RegisterMsg $WM_MOVE. But if I move the MainGUI, the ChildGUI will be disabled, and the Menu grayout Here is the Example code: expandcollapse popup#include <WindowsConstants.au3> #include <misc.au3> #include <GuiMenu.au3> #include <GUIConstantsEx.au3> ;Main GUI wird erstellt $hGui = GUICreate("My GUI", 300, 200) ;Menü färben button $MenuColBtn = GUICtrlCreateButton("Menü Färben", 110, 140, 70, 20) GUISetState() $aWgp = WinGetPos($hGUI) $hChildGUI = GUICreate("",200,25,$aWgp[0]+40,$aWgp[1]+40,$WS_POPUP,$WS_EX_TOOLWINDOW,$hGui) ;Menüs werden erstellt $FileMenu = GUICtrlCreateMenu("&Datei") $OpenItem = GUICtrlCreateMenuItem("&Öffnen", $FileMenu) $SaveItem = GUICtrlCreateMenuItem("&Speichern", $FileMenu) GUICtrlCreateMenuItem("", $FileMenu) $OptionsMenu = GUICtrlCreateMenu("O&ptionen", $FileMenu) $ViewItem = GUICtrlCreateMenuItem("Aussehen", $OptionsMenu) GUICtrlCreateMenuItem("", $OptionsMenu) $ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu) GUICtrlCreateMenuItem("", $FileMenu) $ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu) $HelpMenu = GUICtrlCreateMenu("&?") $AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu) ;GUI wird gezeigt _SetColorOfMenu(0xbbbb) GUISetState() GUIRegisterMsg($WM_MOVE, "WM_MOVE") While 1 Switch GUIGetMsg() Case - 3 ExitLoop Case $MenuColBtn $clr = _ChooseColor() If @error Then ContinueLoop _SetColorOfMenu($clr) Case $AboutItem MsgBox(64, "About...", "") EndSwitch WEnd Func _SetColorOfMenu($hColor) If @OSVersion <> "WIN_95" And @OSVersion <> "WIN_NT4" Then _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($FileMenu), _WinAPI_CreateSolidBrush($hColor)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($OptionsMenu), _WinAPI_CreateSolidBrush($hColor - 0x002200)) _GUICtrlMenu_SetMenuBackground(GUICtrlGetHandle($HelpMenu), _WinAPI_CreateSolidBrush($hColor)) $hmenu = _GUICtrlMenu_GetMenu($hChildGUI) _GUICtrlMenu_SetMenuBackground($hmenu, _WinAPI_CreateSolidBrush($hColor)) GUISwitch($hChildGUI) GUISetState(@SW_HIDE) GUISetState() Return 1 EndIf Return 0 EndFunc ;==>_SetColorOfMenu Func WM_MOVE($hWndGUI) If $hWndGUI <> $hGUI Then Return $GUI_RUNDEFMSG Local $aWgp = WinGetPos($hWndGUI) WinMove($hChildGUI, "", $aWgp[0]+40, $aWgp[1]+40) EndFunc I hope someone can help me (Sorry for my exotic questions^^) Mfg / Best Regards Spider www.AutoIt.de - Moderator of the German AutoIt Forum
GtaSpider Posted January 28, 2008 Author Posted January 28, 2008 No one an idea? Im also lucky about other Resulotions. I want only change the menu width and the menu pos.. Mfg / Best Regarz Spider www.AutoIt.de - Moderator of the German AutoIt Forum
GaryFrost Posted January 28, 2008 Posted January 28, 2008 No one an idea? Im also lucky about other Resulotions. I want only change the menu width and the menu pos.. Mfg / Best Regarz Spider Func WM_MOVE($hWndGUI) If $hWndGUI <> $hGUI Then Return $GUI_RUNDEFMSG Local $aWgp = WinGetPos($hWndGUI) WinMove($hChildGUI, "", $aWgp[0]+40, $aWgp[1]+40) WinActivate($hChildGUI) EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GtaSpider Posted January 28, 2008 Author Posted January 28, 2008 Hello thank you for posting, but it doesnt work.. Main problem is, that the GUI Lagging extremely.. Second problem is, that the MainGUI isnt active.. I'll that both guis are Enabled Or have you an other solution to change the Width and the position of the Menu? Thank you for your comments Mfg / Best Regadz Spider www.AutoIt.de - Moderator of the German AutoIt Forum
GaryFrost Posted January 28, 2008 Posted January 28, 2008 Hellothank you for posting, but it doesnt work..Main problem is, that the GUI Lagging extremely..Second problem is, that the MainGUI isnt active..I'll that both guis are Enabled Or have you an other solution to change the Width and the position of the Menu?Thank you for your comments Mfg / Best Regadz SpiderThe reason it grays out is because you can only have 1 window/gui active at a time, the grayed menu is because that gui isn't the active gui/window. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
GtaSpider Posted January 28, 2008 Author Posted January 28, 2008 Hello Yes, sounds true.. So is there an other sulotion to change the width and pos of the Menu? Thanks MFG / best regars spider www.AutoIt.de - Moderator of the German AutoIt Forum
torun Posted January 29, 2008 Posted January 29, 2008 I found several examples where the titlebar is customized (color, bitmap, gradient etc):codeguruCustom title barsWin32 tips and tricksThe way they go is to intercept WM_NCPAINT and draw on the title bar area.case WM_NCPAINT: { HDC hdc; hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN); // Paint into this DC ReleaseDC(hwnd, hdc); }for painting:void PaintRect(HDC hdc, RECT *rect, COLORREF colour) { COLORREF oldcr = SetBkColor(hdc, colour); ExtTextOut(hdc, 0, 0, ETO_OPAQUE, rect, "", 0, 0); SetBkColor(hdc, oldcr); }Perhaps the experts can translate this to AutoIt code.There are many examples floating around in other programming languages, look for WM_NCPAINT and 'title bar'.
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