Sign in to follow this  
Followers 0
Cotino

GuiCtrlSetGraphic after @SW_SHOW

2 posts in this topic

#1 ·  Posted (edited)

Hi,

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)
GUISetOnEvent($GUI_EVENT_CLOSE, "EndGUI", $GUI1)

$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)
GUISetOnEvent($GUI_EVENT_CLOSE, "EndGUI", $GUI2)

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
    Sleep(1000)
WEnd

Func  EndGUI()
     Exit
EndFunc

 

Edit : typo

 

My bad, found the answer myself.

Add

GUICtrlSetGraphic($graphic,$GUI_GR_REFRESH)
Edited by Cotino

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  
Followers 0