morion84

GUI CreateGraphic issue

3 posts in this topic

#1 ·  Posted

Hi, maybe someone will have an idea about my issue. I create a GUI then two GUICtrlCreateGraphic objects one by one. The first one should be visible as square, and second one as a line.

Unfortunately only the first square is being displayed at script start, and I have to minimalized Gui window and bring it back to see second graphic object (line). Is there any way to display both graphics as it is?

Thank You.

 

graph.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted

Move the line that shows the GUI to the end, after all the controls are drawn

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>

Global $iWidth = @DesktopWidth - @DesktopWidth*15/100
Global $iHeight =   @DesktopHeight - @DesktopHeight*15/100
$iScale = 3
Global $iSquareH    =   14*$iScale
Global $aSquares[0][3]
Global $iSquaresRows = 0
Global $aPaths[0][3]
Global $iPathsRows = 0
Global $aCurrentPos[2]
$aCurrentPos[0] = $iWidth/2
$aCurrentPos[1] = $iHeight/2

Opt("GUIOnEventMode" , 1)
$gui=GUICreate("Graph" , $iWidth, $iHeight)
$gBN = GUICtrlCreateButton("N", 40, 10, 30, 30)
$gBW = GUICtrlCreateButton("W", 10, 40, 30, 30)
$gBNW = GUICtrlCreateButton("NW", 10, 10, 30, 30)
$gBNE = GUICtrlCreateButton("NE", 70, 10, 30, 30)
$gBE = GUICtrlCreateButton("E", 70, 40, 30, 30)
$gBS = GUICtrlCreateButton("S", 40, 70, 30, 30)
$gBSW = GUICtrlCreateButton("SW", 10, 70, 30, 30)
$gBSE = GUICtrlCreateButton("SE", 70, 70, 30, 30)

GUISetBkColor($COLOR_WHITE)
GUISetOnEvent($GUI_EVENT_CLOSE , "quit")

ReDim $aSquares[UBound($aSquares , 1) + 1][3]
$aSquares[UBound($aSquares , 1) - 1][0] = GUICtrlCreateGraphic($aCurrentPos[0], $aCurrentPos[1], $iSquareH, $iSquareH)
$aSquares[UBound($aSquares , 1) - 1][1] = $aCurrentPos[0]
$aSquares[UBound($aSquares , 1) - 1][2] = $aCurrentPos[1]
GUICtrlSetColor($aSquares[UBound($aSquares , 1) - 1][0], $COLOR_BLACK)
GUICtrlSetBkColor(-1, 0x66ff99)

ReDim $aPaths[UBound($aPaths , 1) + 1][3]
$aPaths[UBound($aPaths , 1) - 1][0] = GUICtrlCreateGraphic($aCurrentPos[0]-$iSquareH, $aCurrentPos[1], $iSquareH, $iSquareH)
$aPaths[UBound($aPaths , 1) - 1][1] = $aCurrentPos[0]-$iSquareH
$aPaths[UBound($aPaths , 1) - 1][2] = $aCurrentPos[1]
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_MOVE, 0, $iSquareH/2)
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_COLOR, $COLOR_BLACK)
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_LINE, $iSquareH, $iSquareH/2)
GUISetState(@SW_SHOW)


While 1
Sleep(10)
WEnd

Func quit()
    Exit 1
EndFunc

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thank You, but it's became stop usefull when You want to make a future updates and You don't want to refresh windows by hiding it and bringing back GUISETSTATE(@SW_HIDE) and GUISETSTATE(@SW_SHOW) also work, but it's not nice when window is blinking. My current solution is to create graphic in any place then move it into it's final direction.

Works well up to now.

Thank You once again for Your reply.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>

Global $iWidth = @DesktopWidth - @DesktopWidth*15/100
Global $iHeight =   @DesktopHeight - @DesktopHeight*15/100
$iScale = 3
Global $iSquareH    =   14*$iScale
Global $aSquares[0][3]
Global $iSquaresRows = 0
Global $aPaths[0][3]
Global $iPathsRows = 0
Global $aCurrentPos[2]
$aCurrentPos[0] = $iWidth/2
$aCurrentPos[1] = $iHeight/2

Opt("GUIOnEventMode" , 1)
$gui=GUICreate("Graph" , $iWidth, $iHeight)
$gBN = GUICtrlCreateButton("N", 40, 10, 30, 30)
$gBW = GUICtrlCreateButton("W", 10, 40, 30, 30)
$gBNW = GUICtrlCreateButton("NW", 10, 10, 30, 30)
$gBNE = GUICtrlCreateButton("NE", 70, 10, 30, 30)
$gBE = GUICtrlCreateButton("E", 70, 40, 30, 30)
$gBS = GUICtrlCreateButton("S", 40, 70, 30, 30)
$gBSW = GUICtrlCreateButton("SW", 10, 70, 30, 30)
$gBSE = GUICtrlCreateButton("SE", 70, 70, 30, 30)



GUISetState(@SW_SHOW)
GUISetBkColor($COLOR_WHITE)
GUISetOnEvent($GUI_EVENT_CLOSE , "quit")

ReDim $aPaths[UBound($aPaths , 1) + 1][3]
$aPaths[UBound($aPaths , 1) - 1][0] = GUICtrlCreateGraphic($aCurrentPos[0]-$iSquareH-1, $aCurrentPos[1], $iSquareH, $iSquareH)
$aPaths[UBound($aPaths , 1) - 1][1] = $aCurrentPos[0]-$iSquareH
$aPaths[UBound($aPaths , 1) - 1][2] = $aCurrentPos[1]
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_MOVE, 0, $iSquareH/2)
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_COLOR, $COLOR_BLACK)
GUICtrlSetGraphic($aPaths[UBound($aPaths , 1) - 1][0], $GUI_GR_LINE, $iSquareH, $iSquareH/2)

GUICtrlSetPos($aPaths[UBound($aPaths , 1) - 1][0], $aPaths[UBound($aPaths , 1) - 1][1], $aPaths[UBound($aPaths , 1) - 1][2])

ReDim $aSquares[UBound($aSquares , 1) + 1][3]
$aSquares[UBound($aSquares , 1) - 1][0] = GUICtrlCreateGraphic($aCurrentPos[0], $aCurrentPos[1], $iSquareH, $iSquareH)
$aSquares[UBound($aSquares , 1) - 1][1] = $aCurrentPos[0]
$aSquares[UBound($aSquares , 1) - 1][2] = $aCurrentPos[1]
GUICtrlSetColor($aSquares[UBound($aSquares , 1) - 1][0], $COLOR_BLACK)
GUICtrlSetBkColor(-1, 0x66ff99)





While 1
Sleep(10)
WEnd

Func quit()
    Exit 1
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