Jump to content

GuiCtrlSetGraphic after @SW_SHOW

Recommended Posts


I create a graphic through GUICtrlCreateGraphic, make a nice beautiful reactangle, then show the gui. After that, i want to create another rectangle, however it just won't show. If i hide and then show the GUI again, the rectangle appear.

Is there any way to show the rectangle without having to go through that ? Having the window flicker as it hides then show again is not ideal.


#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

$GUI1 = GUICreate("GUI1", 200, 200, -1, -1)

$graphic = GUICtrlCreateGraphic(0, 0, 200, 200)
GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, 0xFF0000, 0xFF0000)
GUICtrlSetGraphic($graphic, $GUI_GR_RECT, 10, 10, 180, 180)

$GUI2 = GUICreate("GUI2", 200, 200, -1, -1)

GUISetState(@SW_SHOW, $GUI1)

MsgBox(0,"","Creating blue rectangle")
GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, 0x0000FF, 0x0000FF)
GUICtrlSetGraphic($graphic, $GUI_GR_RECT, 50, 50, 100, 100)

GUISetState(@SW_HIDE, $GUI1) ; // Comment these 2 and the blue rectangle won't appear
GUISetState(@SW_SHOW, $GUI1) ; //

While 1

Func  EndGUI()


Edit : typo


My bad, found the answer myself.


Edited by Cotino
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...