Jump to content
Sign in to follow this  
jhonson

Button flickering on GUI

Recommended Posts

Hello, i'm learning autoit and i have come up with a problem. I wanted to create a help window from a button click, everything works clean except for the button which flickers. The flickering stops when i remove "GUICtrlSetState($help, $GUI_ENABLE)" line from the script and also when the "help" or "ok" button is clicked the flickering stops. What am i doing wrong?

#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$main = GUICreate("",  317, 317, 1030, 115, $WS_POPUPWINDOW ,$WS_EX_TOPMOST)
GUICtrlCreateLabel("", 0, 0, 222, 30, -1, $GUI_WS_EX_PARENTDRAG)
Global $helpwindow = 9999, $ok
GUISetState(@SW_SHOW)

HotKeySet ("{numpad9}", "MyExit")

$help = GUICtrlCreateButton("", 227, 3, 24, 24)

While 1
   $msg = GUIGetMsg()
   Select

      Case $msg = $help
         GUICtrlSetState($help, $GUI_DISABLE)
         $helpwindow = GUICreate("",  317, 317, 1030, 115, $WS_POPUPWINDOW ,$WS_EX_TOPMOST)
         GUISetState(@SW_SHOW)
         $ok = GUICtrlCreateButton("OK", 161, 277, 150, 34)

      Case $msg = $ok
         GUIDelete($helpwindow)
         GUICtrlSetState($help, $GUI_ENABLE) ;flickering stops when this line is removed

 EndSelect
WEnd

Func MyExit()
   Exit
EndFunc

 

Share this post


Link to post
Share on other sites
#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$main = GUICreate("",  317, 317, 1030, 115, $WS_POPUPWINDOW ,$WS_EX_TOPMOST)
$help = GUICtrlCreateButton("", 227, 3, 24, 24)
GUICtrlCreateLabel("", 0, 0, 222, 30, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState(@SW_SHOW)

$helpwindow = GUICreate("",  317, 317, 1030, 115, $WS_POPUPWINDOW ,$WS_EX_TOPMOST)
$ok = GUICtrlCreateButton("OK", 161, 277, 150, 34)

HotKeySet ("{numpad9}", "MyExit")

While 1
   $msg = GUIGetMsg()
   Select

      Case $msg = $help
         GUISetState(@SW_SHOW, $helpwindow)
         GUICtrlSetState($help, $GUI_DISABLE)

      Case $msg = $ok
         GUISetState(@SW_HIDE, $helpwindow)
         GUICtrlSetState($help, $GUI_ENABLE)

 EndSelect
WEnd

Func MyExit()
   Exit
EndFunc

 

Edited by Zedna

Share this post


Link to post
Share on other sites

You do not even need 2 GUIs.  Just one would work like this :

;#RequireAdmin
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$main = GUICreate("",  317, 317, 1030, 115, $WS_POPUPWINDOW ,$WS_EX_TOPMOST)
$help = GUICtrlCreateButton("", 227, 3, 24, 24)
GUICtrlCreateLabel("", 0, 0, 222, 30, -1, $GUI_WS_EX_PARENTDRAG)
$ok = GUICtrlCreateButton("OK", 161, 277, 150, 34)
GUICtrlSetState (-1, $GUI_HIDE)
GUISetState(@SW_SHOW)

HotKeySet ("{numpad9}", "MyExit")

While 1
   Switch GUIGetMsg()
      Case $help
         GUICtrlSetState($ok, $GUI_SHOW)
         GUICtrlSetState($help, $GUI_HIDE)
      Case $ok
         GUICtrlSetState($ok, $GUI_HIDE)
         GUICtrlSetState($help, $GUI_SHOW)
   EndSwitch

WEnd

Func MyExit()
   Exit
EndFunc

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...