Sign in to follow this  
Followers 0
Hypertrophy

ANYGUI problem deleting pictures created on target

14 posts in this topic

#1 ·  Posted (edited)

The code below creates pictures on the current window in the loop by a method of inireading and so forth. What is important and what I'm having trouble with is at the beginning of my function I want to delete all of the pictures created by _TargetAddPic().

For example, I have two external windows running and I "embed" and create a picture on each external window using _TargetAddPic(). So far everything is perfect. Well after it has finished running through the loop it goes back to the beginning of the function. What I want to do is when it starts over again I want to delete ALL pictures on the external windows before continuing in the function and I dont know how to do this. I attempted as you will see below but failed >_<

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MY GOAL AND WHAT I NEED HELP WITH IS TO CREATE LITTLE
; PICTURES ON EXTERNAL WINDOWS USING ANYGUI. THE REASON I
; WANT TO USE ANYGUI IS BECAUSE IT "EMBEDS" THE PICTURES
; INTO THE TARGET WINDOW SO THEY WILL MOVE WITH AND
; MINIMIZE WITH THE TARGET WINDOW


; MY PROBLEM IS AT THE BEGINNING OF THIS FUNCTION I WANT
; TO --DELETE-- ALL EXISTING PICTURES CREATED BY ANYGUI
; USING THE _TARGETADDPIC(). I TRY TO DO THIS ON LINE
; 18 BUT IT'S NOT COMPLETELY WORKING. PLEASE HELP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func Test()
    If ProcessExists("Application.exe") Then

        ;-------------------------------------------------
        For $i = 1 To $ahInput[0][0]
                GUIDelete($ahInput[$i][0])  ; delete all little pictures created by _TargetAddPic() (NOT WORKING)
        Next
        ;-------------------------------------------------

        $string = "Test" & StringReplace(StringTrimRight(_NowCalc(),8), "/","") 

        $ftpname = IniRead(@ScriptDir & "\data\Config.dat", "Section", "Logging", "")
        $array = StringSplit($ftpname, "\")
        $i = $array[0]  
        $ftpname = $array[$i]

        If $ftpname = "" Then   ; either the user hasn't set Logging location yet or has done it incorrectly
            MsgBox(0, "", "Configure your Logging location in the settings window.")
        EndIf

        $hhf_dir = IniRead(@ScriptDir & "\data\Config.dat", "Section", "Logging", "")

        $list = WinList("[CLASS:QWidget]")  ; list all windows with classname QWidget
        For $n = 1 To $list[0][0]
            If $list[$n][0] <> "" AND IsVisible($list[$n][1]) Then  ; if window is visible and has a title
                If $list[$n][0] = "Window Name Test Window " & $ftpname Then        ; skip this window
                Else
                    ; store the path of the file
                    $path = $hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt"

                    ; open for reading
                    $hh = FileOpen($hhf_dir & "\" & $string & "" & StringTrimRight(StringReplace($list[$n][0], "/", "-"), StringLen($ftpname) + 16) & ".txt", 0)
                    If $hh = -1  Then
                        ContinueLoop
                    EndIf
                    
                    ; close file
                    FileClose($hh)

                    $target = _GUITarget($list[$n][0]   ; HERE'S THE ANYGUI CODE --- I WANT TO TARGET THE CURRENT WINDOW IN THE LOOP

                    $count = _FileCountLines($path)

                    For $s=10 To 0 Step -1
                        $line = FileReadLine($path, $count - $s)
                        FileWrite(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt", $line & @CRLF)
                    Next
                    $readtemp = FileRead(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")

                    ; read temp data into array
                    _FileReadToArray(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt", $asArray)

                    $sectionNAMES=IniReadSectionNames($datfile)
                    For $t=1 To $sectionNAMES[0]    
                        $section = IniReadSection($datfile, "Section" & $t)
                        For $i=1 To $section[0][0]  
                            If StringInStr($readtemp, $section[$i][0]) Then
                                $split = StringSplit($section[$i][1], ",")  
                                For $x = 1 To $split[0]
                                    If $split[$x] = "Info/data" Then
                                        For $q = 1 To $asArray[0]
                                            If StringInStr($asArray[$q],$section[$i][0]) > 0 Then   
                                                If StringLeft($asArray[$q],5) = "Seat " Then
                                                    $Seat = StringMid($asArray[$q],6,1)
                                                    IniWrite(@ScriptDir & "\data\test.ini", $list[$n][0], $section[$i][0] & "*Seat" & $Seat, "Info/data")
                                                EndIf
                                            EndIf
                                        Next
                                    EndIf
                                Next
                            EndIf
                        Next
                    Next
                    FileDelete(@ScriptDir & "\data\" & StringReplace($list[$n][0], "/", "-") & ".txt")

                    $names = IniReadSectionNames(@ScriptDir & "\data\test.ini")
                    If IsArray($names) Then
                    For $e=1 To $names[0]   ; for each section name
                        $dumpsection = IniReadSection(@ScriptDir & "\data\test.ini", $names[$e])
                        For $a=1 To $dumpsection[0][0]  ; for each key/value in section
                            $secondsplit = StringSplit($dumpsection[$a][0], "*")
                            For $g=1 To $secondsplit[0]
                                If $secondsplit[$g] = "Seat1" Then
                                    $current_tilt_win = WinGetPos($names[$e])
                                    $ahInput[0][0] += 1
                                    ReDim $ahInput[$ahInput[0][0] + 1][6]
                                    
                                    ; HERE'S WHERE I ADD A PIC ONTO THE WINDOW
                                    $ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 100, 100, 26, 26, -1, -1, $target)

                                    
                                    #cs -- HERE'S THE OLD METHOD I USED TO CREATE WINDOWS ON AN EXTERNAL APP --
                                    
                                    $ahInput[$ahInput[0][0]][0] = GUICreate(StringTrimRight($dumpsection[$a][0], 6), 26, 26, $current_tilt_win[0] + 454, $current_tilt_win[1] + 139, _
                                    $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
                                    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 0, 0, 26, 26, -1)
                                    
                                    #ce
                                ElseIf $secondsplit[$g] = "Seat2" Then
                                    $current_tilt_win = WinGetPos($names[$e])
                                    $ahInput[0][0] += 1
                                    ReDim $ahInput[$ahInput[0][0] + 1][6]
                                    
                                    ; HERE'S WHERE I ADD A PIC ONTO THE WINDOW
                                    $ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 204, 141, 26, 26, -1, -1, $target)


                                    #cs -- HERE'S THE OLD METHOD I USED TO CREATE WINDOWS ON AN EXTERNAL APP --
                                    
                                    $ahInput[$ahInput[0][0]][0] = GUICreate(StringTrimRight($dumpsection[$a][0], 6), 26, 26, $current_tilt_win[0] + 628, $current_tilt_win[1] + 219, _
                                    $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
                                    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 0, 0, 26, 26, -1)
                                    
                                    #ce 
                            Next
                        Next
                    Next
                    EndIf
                    FileDelete(@ScriptDir & "\data\test.ini")
                EndIf
            EndIf
        Next
    EndIf
EndFunc
Edited by Hypertrophy

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Forgive me but I have no experience whatsoever with GDI+. Could you assist me in implementing your code into my example above?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Ok, here it is.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Thank you very much. I don't know how familiar you are with anygui but do you know if there is a way to delete all the pictures created by _TargetAddPic. Would I use GUIDelete($pichandle)? You have any ideas?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

The forum rules say wait 24 hours before bumping your post. You're welcome for me doing again for you, please respect the rest of us with questions, and don't bump more than once every 24 hours.

Share this post


Link to post
Share on other sites

Yeah its not working. I am creating multiple pictures using _TargetAddPic() and I want to be able to delete them all.

Im creating them like this

$target = _GuiTarget($list[$n][0], 1)
$ahInput[$ahInput[0][0]][0] = _TargetAddPic(@ScriptDir & "\folder\" & $dumpsection[$a][1] & ".gif", 454, 139, 26, 26, -1, -1, $target)

And at the beginning of my function I do

_EndTarget()

but I dont see them disappear...

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

But is there any way to just delete them? I dont want to hide them. Like a global function or something? thanks for all of your help so far.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

---

Edited by playlet

Share this post


Link to post
Share on other sites

Been posting in his thread and no one answers. Quite frustrating >_

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