Jewtus Posted August 27, 2014 Posted August 27, 2014 (edited) Im having some trouble with toggling an image. This is what I have: $sqlRs10 = ObjCreate("ADODB.Recordset") $sqlRs10.open ("Select [Status] from Request where RequestID like '%"&$metaSearchID&"%'", $sqlCon) $lockstatus=$sqlRs10.GetRows If IsArray($lockstatus) <> 0 Then _ArrayDisplay($lockstatus) If $lockstatus[0][0] = 10 Then $Lock = GUICtrlCreatePic("C:\Users\x345705\Desktop\LockPhoto.jpg", 336, 408, 36, 36) ElseIf $lockstatus[0][0] <> 10 Then $UnLock = GUICtrlCreatePic("C:\Users\x345705\Desktop\UnlockPhoto.jpg", 336, 408, 36, 36) EndIf EndIf The array shows up with the status, but neither of the images are never created... In addition to that, I'm trying to make it so when I click the button, it sends an update statement and changes the image. Anyone have any suggestions? Edited August 27, 2014 by Jewtus
Jewtus Posted August 27, 2014 Author Posted August 27, 2014 Well, I'm a fool... It was creating the objects but it was underneath another object in the GUI... OOPS! Still can't quite figure out how to create an on click event for that object though
JohnOne Posted August 27, 2014 Posted August 27, 2014 Just treat the pic control as a button. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Jewtus Posted August 27, 2014 Author Posted August 27, 2014 (edited) On 8/27/2014 at 12:33 PM, JohnOne said: Just treat the pic control as a button. There is a problem with that... When I put: Case $Unlocker MsgBox(0,"","Toggle case Lock") and run the script I get this error: "SSI Tool.au3" (277) : ==> Variable used without being declared.: Case $Unlocker Case ^ ERROR and when I declare the variable at the beginning of the script using Global $Unlocker, I get the message box constantly. EDIT: I should have mentioned that I tweaked it to a button: $sqlRs10 = ObjCreate("ADODB.Recordset") $sqlRs10.open ("Select [Status] from Request where RequestID like '%"&$metaSearchID&"%'", $sqlCon) $lockstatus=$sqlRs10.GetRows If IsArray($lockstatus) <> 0 Then $Unlocker= GUICtrlCreateButton("Unlocker", 235, 512, 40, 40, $BS_BITMAP) If $lockstatus[0][0] = 10 Then MsgBox(0,"",@ScriptDir&"\LockPhoto.jpg") GUICtrlSetImage($Unlocker, @ScriptDir&"\LockPhoto.bmp") ElseIf $lockstatus[0][0] <> 10 Then MsgBox(0,"",@ScriptDir&"\UnLockPhoto.jpg") GUICtrlSetImage($Unlocker, @ScriptDir&"\UnLockPhoto.bmp") EndIf EndIf Edited August 27, 2014 by Jewtus
Solution tlman12 Posted August 27, 2014 Solution Posted August 27, 2014 it may be saying that because your defining $unlocker within an if statement and if there is no logic for $unlocker to be created then there is no variable for a case statement (without seeing more of your code i can't be sure) try creating the unlocker button during the gui creation and then do a GUICtrlSetState(-1,$GUI_HIDE) right below it then in your if statement (if logic says for the button to be available do GUICtrlSetState(-1,$GUI_SHOW) that way there is no possibility of $unlocker being undefined.
JohnOne Posted August 27, 2014 Posted August 27, 2014 A simple working reproducer would be nice. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Jewtus Posted August 27, 2014 Author Posted August 27, 2014 (edited) On 8/27/2014 at 2:12 PM, tlman12 said: it may be saying that because your defining $unlocker within an if statement and if there is no logic for $unlocker to be created then there is no variable for a case statement (without seeing more of your code i can't be sure) try creating the unlocker button during the gui creation and then do a GUICtrlSetState(-1,$GUI_HIDE) right below it then in your if statement (if logic says for the button to be available do GUICtrlSetState(-1,$GUI_SHOW) that way there is no possibility of $unlocker being undefined. That was it... I was trying to create and delete it under circumstances... Hiding it is much more effective. Edited August 27, 2014 by Jewtus
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