John117 Posted June 19, 2007 Share Posted June 19, 2007 I have buttons that add pictures to a GUI that contains ABC's as buttons. When each button is pressed it loads a picture related to it that is named according to the letter. EX Pressing A opens A.jpg Here's the problem. For a reason unknown to me, it must be pressed or called twice to pull the image. Works perfectly well the first time used once opened, But it must be pressed twice after that. CODEGuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) works to avoid the pressing twice but causes a flicker. Is there a way to delete all images on a GUI? ex button press = Delete all images or specific image then GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) or some other idea to avoid the lack of update or flicker? ???? Thanks for the help! Link to comment Share on other sites More sharing options...
Gif Posted June 19, 2007 Share Posted June 19, 2007 (edited) I have buttons that add pictures to a GUI that contains ABC's as buttons. When each button is pressed it loads a picture related to it that is named according to the letter. EX Pressing A opens A.jpg Here's the problem. For a reason unknown to me, it must be pressed or called twice to pull the image. Works perfectly well the first time used once opened, But it must be pressed twice after that. CODEGuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) works to avoid the pressing twice but causes a flicker. Is there a way to delete all images on a GUI? ex button press = Delete all images or specific image then GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) or some other idea to avoid the lack of update or flicker? ???? Thanks for the help! 2 things i think you should use: GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) GuiCtrlSetState(-1, $GUI_DISABLE) and to delete use GuiCtrlDelete() Edited June 19, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
John117 Posted June 19, 2007 Author Share Posted June 19, 2007 2 things i think you should use: c2--><!--R3VpQ3RybENyZWF0ZVBpYygmcXVvdDtDOiYjMDkyO0F1dG9JdEFCQyYjMzk7cyYjMDkyOyZxdW90OyAmYW1wOyBDaHIoNjUrJiMw MzY7WCkgJmFtcDsgJnF1b3Q7LmpwZyZxdW90OywgMzUwLCAxMjAsIDEwNiwgNzUpCkd1aUN0cmxTZXRTdGF0ZSgtMSwgJiMwMzY7 R1VJX0RJU0FCTEUp--><!--eg and to delete use GuiCtrlDelete() Your suggestion worked just as needed! Thanks a million! Link to comment Share on other sites More sharing options...
John117 Posted June 19, 2007 Author Share Posted June 19, 2007 Your suggestion worked just as needed! Thanks a million!Is there a way to use this for multiple pictures?Say I add two pictures.1. A.jpg2. A2.jpgThen delete both?Also the code does work for one if a set a timer and delete while the script is still running. I was hoping to add the delete at the top so that it would delete only when another letter is pressed . . .Any ideas?Thanks for your help! Link to comment Share on other sites More sharing options...
John117 Posted June 20, 2007 Author Share Posted June 20, 2007 Bump Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 20, 2007 Share Posted June 20, 2007 (edited) Here's the problem. For a reason unknown to me, it must be pressed or called twice to pull the image. Works perfectly well the first time used once opened, But it must be pressed twice after that. GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) works to avoid the pressing twice but causes a flicker. Is there a way to delete all images on a GUI? ex button press = Delete all images or specific image then GuiCtrlCreatePic("C:\AutoItABC's\" & Chr(65+$X) & ".jpg", 350, 120, 106, 75) Are you creating the Pic over and over again? That's not the idea. You only create the Pic control ONCE with GuiCtrlCreatePic(), and save the control ID to variable. Then to change the picuture you just use the control ID to set a new image with GuiCtrlSetImage(). Demo: expandcollapse popup#include <guiconstants.au3> Opt("GuiOnEventMode", 1) $PicDir = FileSelectFolder("Select a directory with JPGs in it:", "", 4) If @error Then Exit $hSearch = FileFindFirstFile($PicDir & "\*.jpg") If @error Or $hSearch = -1 Then MsgBox(16, "Error", "No .jpg file found: " & $PicDir) Exit EndIf GUICreate("Picture Test", 300, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $PicCtrl = GUICtrlCreatePic("", 10, 10, 280, 280) $Label = GUICtrlCreateLabel("", 10, 300, 280, 20, $SS_CENTER) GUICtrlCreateButton("NEXT", 120, 330, 60, 30) GUICtrlSetOnEvent(-1, "_Next") _Next() GUISetState() While 1 Sleep(20) WEnd Func _Next() $PicFile = FileFindNextFile($hSearch) If @error Then MsgBox(64, "Done", "No more .jpg files.") Exit Else GUICtrlSetImage($PicCtrl, $PicDir & "\" & $PicFile) EndIf EndFunc ;==>_Next Func _Quit() Exit EndFunc ;==>_Quit Edited June 20, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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