Jump to content

Image toggle issues


Go to solution Solved by tlman12,

Recommended Posts

Posted (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 by Jewtus
Posted

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

Posted (edited)

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 by Jewtus
  • Solution
Posted

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.

Posted (edited)

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 by Jewtus

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...