Jump to content

[SOLVED] Change tray menu text color


nend
 Share

Recommended Posts

I've found a way to change the back ground color but not a way to change the text color of the menu.

I've found this in the helpfile to change the background.

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Global Const $MIM_APPLYTOSUBMENUS = 0x80000000, $MIM_BACKGROUND = 0x00000002 ; Constants required for SetMenuColor

Example()

Func Example()
    Local $idSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
    Local $idDisplay = TrayCreateItem("Display", $idSettings)
    Local $idPrinter = TrayCreateItem("Printer", $idSettings)
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    SetMenuColor(0, 0xEEBB99) ; BGR color value, '0' refers to the tray menu itself.
    SetMenuColor($idSettings, 0x66BB99); BGR color value for the 'Settings' menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idDisplay, $idPrinter
                MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func SetMenuColor($iMenuID, $iColor)
    Local $hMenu = TrayItemGetHandle($iMenuID) ; Get the internal menu handle

    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $iColor)
    $hBrush = $hBrush[0]

    Local $tMenuInfo = DllStructCreate("dword;dword;dword;uint;ptr;dword;ptr")
    DllStructSetData($tMenuInfo, 1, DllStructGetSize($tMenuInfo))
    DllStructSetData($tMenuInfo, 2, BitOR($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND))
    DllStructSetData($tMenuInfo, 5, $hBrush)

    DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "struct*", $tMenuInfo)
EndFunc   ;==>SetMenuColor

I want to have a black menu with a white font (the same as windows 10 uses in the taskbar menu's)

Have some on has a idea how to do this?

Edited by nend
Link to comment
Share on other sites

13 hours ago, UEZ said:

Something like this here?

 

 

Thanks UEZ but....... I think you read over it, what I'am looking at is a Tray Menu with black background and white text (font).

Were you linked to is a Popup, do you have a idea?

 

Link to comment
Share on other sites

To get a similar W10 effect I would use a self create GUI instead of the build-in tray menu because the tray menu is limited.

Something like this here:

 

or this here:

 

In these examples you have the full control over the result.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ 

If I understand it correct this is'nt possible to do with the traymenu and if I want to have it I have to build it from scratch?

I will look into that but I use a menu system with more than 300 entry and I think it's a bit hard to build, but I wil give it try.

 Thank for the help!

Link to comment
Share on other sites

16 minutes ago, nend said:

If I understand it correct this is'nt possible to do with the traymenu and if I want to have it I have to build it from scratch?

I never thought about to change the text color of a tray menu entry. Maybe it is possible - maybe not.

16 minutes ago, nend said:

I will look into that but I use a menu system with more than 300 entry and I think it's a bit hard to build, but I wil give it try.

With this amount of entries it makes no sense to use the self-built GDI+ GUIs.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

2 minutes ago, UEZ said:

I never thought about to change the bg color of a tray menu. Maybe it is possible - maybe not.

With this amount of entries it makes no sense to use the self-built GDI+ GUIs.

The background color is'nt difficult to change it (it's a peace of code from the helpfile, see the first post) but the problem is if I make the background black the text is also black and won't be vissible.

Here a screenshot with what I try to do.

Left the menu which Atoit make                        Right Tray menu with colors which I want to have

Naamloos.jpg.834e799c4e39b48ce28301214b4

But If it is'nt possible to do I don't have to look futher into this.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...