Sign in to follow this  
Followers 0
tip

GUI Main Menu color?

7 posts in this topic

Hi everybody,

I search the forum and help file but I couldn't find a topic related to it.

Does anyone know a way to change main menu's background color? I found some examples to create a custom colored main menus but they only change the menu items colors. I want to be able to change the color of the whole Main Menu bar even the part I see with out clicking any item :graduated:...

Thanks in advance

Tip


[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Share this post


Link to post
Share on other sites



_GUICtrlMenu_SetMenuBackground


Share this post


Link to post
Share on other sites

Thanks for the reply.

I've seen it while searching in the help file but I couldn't get it working. Even the example in the help file doesn't change menu's color...

Any idea?

Regards

Tip


[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Share this post


Link to post
Share on other sites

Mind posting some of your script?

Not sure that you did create a menu.


Share this post


Link to post
Share on other sites

None of the menu background color functions will change the background color of the menu bar itself, only the dropdown portion of the main menus or sub-menus. As far as I know that would require an owner drawn menu bar and probably isn't worth the trouble. That was the same answer I recieved when I asked Holger about using only icons for the main menu bar too.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

None of the menu background color functions will change the background color of the menu bar itself, only the dropdown portion of the main menus or sub-menus. As far as I know that would require an owner drawn menu bar and probably isn't worth the trouble. That was the same answer I recieved when I asked Holger about using only icons for the main menu bar too.

Oh, shoot. But thanks anyway :graduated:...

Regards

Tip


[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Maybe someone can speed this up to produce your desired effect, or provide a better method.

The following is the help file example for _GUICtrlMenu with the noted lines added, it will take @ 6 seconds to build the array of gray pixels in the menu bar, and then you can use that array to paint them whichever color you desire.

If you throw the pixelsetcolor in the Do Loop it will constantly redraw the pixels, depending on your menu use that may provide a better effect.

#include <GuiMenu.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Array.au3>


Opt('MustDeclareVars', 1)

Global $iMemo
Global Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout

_Main()






Func _Main()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain

    ; Create GUI
    $hGUI = GUICreate("Menu", 150, 300, 0 , 0)

    ; 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()

;=================================================================================================

Dim $gray[1]
Dim $found


For $w = 0 to 150
For $h = 33 to 50

$found = pixelsearch ($w , $h, 150 , 50 , 0xE0E2EB)
_ArrayConcatenate ($gray , $found)

Next
Next


_ArrayDelete ($gray , 0)

For $i = 0 to ubound ($gray) - 1 step + 2
_PixelSetColor($gray[$i], $gray[$i +1], 0xFF0000)
Next

;===================================================================================================
    ; Loop until user exits
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until user exits
    Do


    Until GUIGetMsg() = -3
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

; Modified from http://www.autoitscript.com/forum/index.php?showtopic=7315&view=findpost&p=178779
Func _PixelSetColor($XCoord, $YCoord, $Color)
    Local $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", 0)
    If Not IsArray($dc) Then Return -1
    DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $XCoord, "long", $YCoord, "long", _
            "0x" & StringRegExpReplace(hex($Color,6), "(..)(..)(..)", "\3\2\1")) ; Change to 0xBBGGRR hex colour format.
    DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $dc[0])
EndFunc ;==>_PixelSetColor
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0