Sign in to follow this  
Followers 0
kaisies

GUICtrlSetGraphic (draw stuff) AFTER GUISetState(@SW_SHOW)?!

10 posts in this topic

#1 ·  Posted (edited)

Good morning, 

I've been using AutoIT and built a nice GUI for a tool we need (Aloha POS software, but irrelevant)... I've now come to a spot where I want to display data, and the easiest way seemingly was to draw a set of graphics (bar lines) and then I was going to fill in those lines with red lines corresponding to the data (think the graphical line display of a Windows Defrag:

reinstall-disk-defragmenter-windows-xp-i

Any Graphics drawn prior to GUISetState(@SW_SHOW) properly show, however any Graphics (I'm using $GUI_GR_RECT) do not show?!  I have confirmed this by putting commands prior & after SetState, ones before show, ones after don't.  What am I missing? is there a GUI Refresh? is SetGraphic not intended for this purpose?  I can probably come up with other ways to display this data, but this seemed the most "clean"

Edited by kaisies

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Any chance you could post your code so that we can see what is going on?

We will be able to better help you if we can see exactly what you are talking about.

:)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I know I dumped in way too many includes, I just copied them all from my actual code and haven't ever really cleaned them up :)

This is essentially a proof of concept that is much easier to read, the rects are drawn in $BarGraphs[5] and [6], but [8], which is called after gui(show) does not show.

#Include <String.au3>
#include <Array.au3>
#include <Date.au3>
#Include <WinAPI.au3>
#include <File.au3>
#include <Date.au3>
#include <GuiTab.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>
#include <GuiRichEdit.au3>
 
 
; Constants includes
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <ToolbarConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
 
Global $StandaloneWidth = 840, $StandaloneHeight = 600
$hBtnStandaloneStop = 30
$hBtnStandaloneLabel = 30
 
 
Local $x,$tmp,$tmp2
Local $STLFileListChecked[1][2]
Local $STLSplitTXNData[0]
Local $BarGraphWidth = 720,$BarGraphTop = 75, $BarGraphLeft = 110, $BarGraphHeight = 20, $BarGraphPadding = 10
Local $DateWidth = 90,$DateTop = 75, $DateLeft = 10, $DateHeight = 20, $DatePadding = 10
Local $BarGraphs[14]
Local $lblDates[14]
Local $SearchDate =  @YEAR & "/" & @MON & "/" & @MDAY - 1
 
$StandaloneForm = GUICreate("", $StandaloneWidth, $StandaloneHeight, (@DesktopWidth - $StandaloneWidth) / 2, (@DesktopHeight - $StandaloneHeight) / 2,$WS_SYSMENU)
 
 
For $x = 0 to UBound($BarGraphs)-1
$BarGraphs[$x] = GUICtrlCreateGraphic($BarGraphLeft,$BarGraphTop + ($x * ($BarGraphHeight+$BarGraphPadding)),$BarGraphWidth,$BarGraphHeight)
GUICtrlSetBkColor($BarGraphs[$x],0x00CD00)
Next
 
For $x = 0 to UBound($lblDates)-1
$lblDates[$x] = GUICtrlCreateLabel(_DateAdd("D",-$x,$SearchDate),$DateLeft,$BarGraphTop + ($x * ($DateHeight+$DatePadding)),$DateWidth,$DateHeight)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
Next
 
 
GUICtrlSetGraphic($BarGraphs[5],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[5],$GUI_GR_RECT,10,3,2,8)
 
GUICtrlSetGraphic($BarGraphs[6],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[6],$GUI_GR_RECT,10,3,2,8)
 
Global $lblStandaloneInfo = GuiCtrlCreateLabel("Loading....",5,$StandaloneHeight  - $hBtnStandaloneLabel - 25 - 4,$StandaloneWidth,$hBtnStandaloneLabel)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
 
$btnProcessBatches = GUICtrlCreateButton("Stop", ($StandaloneWidth/2)-4, $StandaloneHeight - $hBtnStandaloneStop - 25 - 4 ,($StandaloneWidth/2)-4,$hBtnStandaloneStop)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
 
GUISetState(@SW_SHOW)
 
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
 
 
 
While 1
;~ msgbox(0,'',"")
$aMsg = GUIGetMsg(1)
Switch $aMsg[1]
Case $StandaloneForm
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
GUIDelete($StandaloneForm)
 
ExitLoop
Case $btnProcessBatches
ExitLoop
EndSwitch
EndSwitch
WEnd
Edited by kaisies

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Use [ autoit] code here [ /autoit] tags to input your code (remove the spaces). This will give you formatting and syntax highlighting. Like so

; code here

:)

Move

GUISetState(@SW_SHOW) ; <<<<<<<<<< this
 
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)

to here

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUISetState(@SW_SHOW) ; <<<<<<<<<<<< here
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

Use [ autoit] code here [ /autoit] tags to input your code (remove the spaces). This will give you formatting and syntax highlighting. Like so

; code here

:)

Move

GUISetState(@SW_SHOW) ; <<<<<<<<<< this
 
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)

to here

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUISetState(@SW_SHOW) ; <<<<<<<<<<<< here

 

I was looking for the <code> on the control bar, thanks!

I'd love to move the @SW_SHOW, but its not that simple.  This is just a proof of concept of if it even can do what I want.  After loading this window, it loops through a text file for each day, loads data, and draws accordingly.  This action can take minutes, so I was really hoping to show the GUI prior to all the data loading, and the GUI updating as it went through the text files, but at least the user can see it loading/what data is showing.  Any thoughts? and thanks for the help so far!

Edited by kaisies

Share this post


Link to post
Share on other sites

I was looking for the <code> on the control bar, thanks!

I'd love to move the @SW_SHOW, but its not that simple.  This is just a proof of concept of if it even can do what I want.  After loading this window, it loops through a text file for each day, loads data, and draws accordingly.  This action can take minutes, so I was really hoping to show the GUI prior to all the data loading, and the GUI updating as it went through the text files, but at least the user can see it loading/what data is showing.  Any thoughts? and thanks for the help so far!

 

After you've gone through the text files and GUICtrlSetData or however you do it, then include another call to GUISetState(@SW_SHOW).

Let me know how that goes.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

After you've gone through the text files and GUICtrlSetData or however you do it, then include another call to GUISetState(@SW_SHOW).

Let me know how that goes.

Unfortunately that doesn't work, that was my first thought as well.  I can add GUISetState(@SW_SHOW) after:

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)

 In the example I posted and it does not show the Rect drawn in $BarGraphs[8] :/  I have even tried referencing the hwnd of the GUI:

 
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
 
GUISetState(@SW_SHOW,$StandaloneForm)
Edited by kaisies

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

In the 3rd parameter of GUICtrlSetGraphic do this:

GUICtrlSetGraphic($firstParam, $secondParam, $GUI_GR_REFRESH) ; set to dynamically refresh the GUI

Like so

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUICtrlSetGraphic($BarGraphs[8], $GUI_GR_REFRESH)
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

 

In the 3rd parameter of GUICtrlSetGraphic do this:

GUICtrlSetGraphic($firstParam, $secondParam, $GUI_GR_REFRESH) ; set to dynamically refresh the GUI

Like so

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUICtrlSetGraphic($BarGraphs[8], $GUI_GR_REFRESH)

 

$GUI_GR_REFRESH certainly did it!

You can't call:

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8,$GUI_GR_REFRESH)

 

but you can:

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_REFRESH)

Share this post


Link to post
Share on other sites

 

$GUI_GR_REFRESH certainly did it!

You can't call:

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8,$GUI_GR_REFRESH)

but you can:

GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_COLOR,0xCD0000)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_RECT,10,3,2,8)
GUICtrlSetGraphic($BarGraphs[8],$GUI_GR_REFRESH)

 

Yep, my example shows that :)

I'm glad we got it figured out :D


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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