Jump to content

Faded Menubar color after WinActivate and AnimateWindow


 Share

Recommended Posts

I found a strange behavior that I wanted to share.  The script below demonstrates the issue.  I set $GUI_EVENT_CLOSE to hide the GUI instead of closing it.  After hiding for 3 seconds it will restore.  Notice the Menubar is slightly dimmed.  I noticed if you activate another open window and re-activate the script GUI it restores the menubar to the normal darker color. 

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Opt("GUIOnEventMode", 1)

Local $hGUI = GUICreate("Test GUI w/ Menu", 300, 200)
Local $idMenu = GUICtrlCreateMenu("Menu")
Local $idMenuItem = GUICtrlCreateMenuItem("Menu Item", $idMenu)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Hide")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Hide()
    GUISetState(@SW_HIDE, $hGUI)
    ToolTip("Hiding for 3 seconds")
    sleep(3000)
    ToolTip("")
    WinActivate($hGUI)
    DllCall("User32.dll", "long", "AnimateWindow", "hwnd", $hGUI, "long", 300, "long", 0x00080000)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Return 0
EndFunc

Func _Exit()
    Exit
EndFunc

Anyone seen this before?  Any ideas for a good workaround without playing winactivate hockey?  I tried _GUICtrlMenu_DrawMenuBar but it didn't have any effect.

Link to comment
Share on other sites

have you tried _WinAPI_RedrawWindow ?

Just tried it, it didn't seem to help.  I could be calling it wrong, but the func is returning 1.

On Win 8.1 the behaviour is "normal", no dimming effect at least for me.

Ah yes, OS flavor.  I should've mentioned.  I'm on Win 7 x64.

Link to comment
Share on other sites

Found a cheap workaround.

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Opt("GUIOnEventMode", 1)

Local $hGUI = GUICreate("Test GUI w/ Menu", 300, 200)
Local $idMenu = GUICtrlCreateMenu("Menu")
Local $idMenuItem = GUICtrlCreateMenuItem("Menu Item", $idMenu)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Hide")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _Hide()
    GUISetState(@SW_HIDE, $hGUI)
    ToolTip("Hiding for 3 seconds")
    sleep(3000)
    ToolTip("")
    WinSetOnTop($hGUI, "", 1)
    DllCall("User32.dll", "long", "AnimateWindow", "hwnd", $hGUI, "long", 300, "long", 0x00080000)
    WinActivate($hGUI, "")
    WinSetOnTop($hGUI, "", 0)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Return 0
EndFunc

Func _Exit()
    Exit
EndFunc
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...