Phaser Posted January 3, 2013 Share Posted January 3, 2013 Hi guys I am trying to add some images to my database processing script so when a figure is reached a tick image shows, if the figure is not reached a red cross shows until that figure is reached. With each data input this bit gets called, it checks the count If $count > 25 Then GUICtrlCreatePic("tick.jpg", 130, 170, 13, 13) Else GUICtrlCreatePic("cross.jpg", 130, 170, 13, 13) EndIf It works perfectly fine but starts to slow down after about 300 entries? is it putting an image on an image each time? should I be doing something else? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 3, 2013 Moderators Share Posted January 3, 2013 Phaser, is it putting an image on an image each time?Exactly what is happening - you fire the loop and create a new control each time you pass through it. I suggest using a flag to indicate which image is being displayed and then only change it when required - deleting the old version: ; Declare a flag and a place holder for the image control Global $fImage_Tick = False, $cImage = 9999 ; Then your If structure looks like this If $count > 25 And $fImage_Tick = False Then ; Delete the current control GUICtrlDelete($cImage) ; Create the new image $cImage = GUICtrlCreatePic("tick.jpg", 130, 170, 13, 13) ; Set the flag to prevent this firing again $fImage_Tick = True ElseIf $count <= 25 And $fImage_Tick = True Then ; Delete the current control GUICtrlDelete($cImage) ; Create the new image $cImage = GUICtrlCreatePic("cross.jpg", 130, 170, 13, 13) ; Clear the flag to prevent this firing again $fImage_Tick = False EndIf Now you only create a new image as the count passes the magic 25 (in either direction) and not every time you pass through the loop. Another little wrinkle would be to create the image control just the once and then use GUICtrlSetImage to change the content - you would still need an If structure like that above to prevent the image flickering. All clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mihaibr Posted January 3, 2013 Share Posted January 3, 2013 (edited) Create the Pic control in your gui. then use GUICtrlSetImage to set the image thereEdit:Erm,Melba was faster xD Edited January 3, 2013 by mihaibr Link to comment Share on other sites More sharing options...
Phaser Posted January 3, 2013 Author Share Posted January 3, 2013 Thanks guys, Melba, the images did appear to flicker thats what made me think it was layering the new image on top each time, then I noticed the grinding get worse, closed the software and reopened it then it worked fine again. Thanks both of you for your help. Link to comment Share on other sites More sharing options...
Phaser Posted January 3, 2013 Author Share Posted January 3, 2013 (edited) @ MelbaAnother little wrinkle would be to create the image control just the once and then use GUICtrlSetImage to change the contentStruggling with this, can you give an example using the above vars please$cImage = GUICtrlCreatePic("tick.jpg", 130, 170, 13, 13)Where do I put $cImage ? Edited January 3, 2013 by Phaser Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 3, 2013 Moderators Share Posted January 3, 2013 Phaser, Does this help: expandcollapse popup#include <GUIConstantsEx.au3> ; Declare a flag Global $fImage_Tick = False $hGUI = GUICreate("Test", 500, 500) ; Create the image control in the GUI $cImage = GUICtrlCreatePic("cross.jpg", 130, 170, 13, 13) GUISetState() ; Set the counter $iCount = 20 ; And get a timestamp $iBegin = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Increase the count every second to simulate your counter increasing through the 25 limit If TimerDiff($iBegin) > 1000 Then $iCount += 1 ; Just for interest we display the counter ConsoleWrite("Count = " & $iCount & @CRLF) ; <<<<<<<<<<<<<<<<<<< ; Now we use the If strcuture I posted earlier If $iCount > 25 And $fImage_Tick = False Then ; Show the tick image GUICtrlSetImage($cImage, "tick.jpg") ; Set the flag to prevent this firing again $fImage_Tick = True ElseIf $iCount <= 25 And $fImage_Tick = True Then ; Show the cross image GUICtrlSetImage($cImage, "cross.jpg") ; Clear the flag to prevent this firing again $fImage_Tick = False EndIf ; And finally we reset the timestamp to wait for the next increase $iBegin = TimerInit() EndIf WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phaser Posted January 3, 2013 Author Share Posted January 3, 2013 Melba, yes it does, just couldn't work out what needed changing on the front end, thanks again, always very helpful, much appreciated ; Create the image control in the GUI $cImage = GUICtrlCreatePic("cross.jpg", 130, 170, 13, 13) That's what I needed, thanks again PS, did try to use the Autoit code but I get a javascript error in my browser status bar, sorry Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now