Jump to content

ModernMenu "border"


dantay9
 Share

Recommended Posts

I am using ModernMenu.au3 by Holger and the code is way over my head. I want to remove the tan border or rim around the black menu items, but I can't seem to find out how to do it.

There is more to my code than this (such as on event hovering), but this is a stripped down version of it that reproduces the problem. Here is an example of the border:

#include "ModernMenuRaw.au3"

$GUI = GUICreate("Gecko Web Browser", 700, 50)

#Region Create Context Menu
_SetMenuBkColor(0x000000)
_SetMenuIconBkColor(0x000000)
_SetMenuTextColor(0xFFFFFF)
_SetMenuSelectBkColor(0xBD4908) ;rgb = 0x0849BD
_SetMenuSelectTextColor(0xFFFFFF)

$GUIContextMenu = GUICtrlCreateMenu("File")
_GUICtrlCreateODMenuItem("Exit", $GUIContextMenu)
#EndRegion Create Context Menu

GUISetState(@SW_SHOW, $GUI)

While 1
    $Msg = GUIGetMsg()

    Switch $Msg
        Case -3
            Exit
    EndSwitch
WEnd

Can someone wade through this script and tell me where I can fix this?

Edited by dantay9
Link to comment
Share on other sites

I did find out that I can use _WinAPI_SetSysColors($COLOR_MENU, 0) to adjust the menu to the color that I want. Sadly, this adjusts all menus, not just the menu I want. I guess I could switch the menu colors back and forth depending on whether or not the correct window is active. Is this the only way, or is there some way to set the menu background color for a specific menu to black since it is ownerdrawn?

Edited by dantay9
Link to comment
Share on other sites

I found a temporary fix for the problem. It works, but isn't pretty.

Global Const $OriginalMenuColor = _WinAPI_GetSysColor($COLOR_MENU)

Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $GUI Then
        If $wParam = 0x00000000 Then
            _WinAPI_SetSysColors($COLOR_MENU, $OriginalMenuColor) ;change menu color to system color
        ElseIf $wParam = 0x00000001 Then
            _WinAPI_SetSysColors($COLOR_MENU, 0) ;change menu color to black
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Func OnAutoItExit()
    _WinAPI_SetSysColors($COLOR_MENU, $OriginalMenuColor) ;change menu color to system color
EndFunc

If someone finds a way to change the color of a specific menu, please tell me.

Edited by dantay9
Link to comment
Share on other sites

This will set all the items of a sub-menu but I have nothing to set individual menu items.

Func _Menu_SetColor($hMenuid,$hColor)
   Local $Hmenu = GUICtrlGetHandle ($hMenuid)
   Local $Hbrush = DllCall ("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $hColor)
   $Hbrush = $Hbrush[0]
   Local $Stmenuinfo = DllStructCreate ("dword;dword;dword;uint;dword;dword;ptr")
   DllStructSetData ($Stmenuinfo, 1, DllStructGetSize ($Stmenuinfo))
   DllStructSetData ($Stmenuinfo, 2, BitOr (0x80000000, 0x00000002))
   DllStructSetData ($Stmenuinfo, 5, $Hbrush)
   DllCall ("user32.dll", "int", "SetMenuInfo", "hwnd", $Hmenu, "ptr", DllStructGetPtr ($Stmenuinfo))
   $Stmenuinfo = 0
EndFunc    ;<===> _Menu_SetColor()

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!"

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...