Sign in to follow this  
Followers 0
Bert

Toolbar dock error

5 posts in this topic

#1 ·  Posted (edited)

I have a script that docks a toolbar to a window. Normally works fine. The problem I'm having is I'm getting a error when I close the parent window. Not all the time, but sometimes I will get a autoit error

MTB2_2.au3 (167) : ==> Subscript used with non-Array variable.:

The code I'm using for the docking is this:

Func _ToolbarDocked()
    $p_win1 = WinGetPos($GUI1);parent
    $p_win2 = WinGetPos($GUI2);toolbar
    if WinExists($GUI1) = 0 then exit
        If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
            $x1 = $p_win1[0]
            $y1 = $p_win1[1]
            $x2 = $p_win1[2] + $x1 - ($xx + 4)
            $y2 = $y1 - ($ya + 25)          
            WinMove($GUI2, "", $x2 + $iniread_12, $y2 + $iniread_14) 
        ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
            $x2 = $p_win2[0]
            $y2 = $p_win2[1]
            $x1 = $p_win2[0] - $p_win1[2] + ($xx + 4)
            $y1 = $y2 + ($ya + 25)
            WinMove($GUI1, "", $x1 + $iniread_13, $y1 + $iniread_15) 
        EndIf
EndFunc   ;==>_ToolbarDocked

This line is causing the problem: ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

Edited by vollyman

Share this post


Link to post
Share on other sites



It appears that the toolbar is a child window, i noticed that i had a problem with a child window and GetCursurInfo()

gafrost noted that i would need to set the state of the window as show before the cursur info would work

maybe for you it could help also

http://www.autoitscript.com/forum/index.ph...st&p=260180

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Actually, if the toolbar is "based" on the parent window

you have

if WinExists($GUI1) = 0 then exit

you could add

if WinExists($GUI2) = 0 then exit ; for the toolbar

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I figured it out. I did this, and it worked fine:

Func _ToolbarDocked()
    $p_win1 = WinGetPos($GUI1);parent
    $p_win2 = WinGetPos($GUI2);toolbar
    if WinExists($GUI1) = 0 then exit
        If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
            $x1 = $p_win1[0]
            $y1 = $p_win1[1]
            $x2 = $p_win1[2] + $x1 - ($xx + 4)
            $y2 = $y1 - ($ya + 25)          
            WinMove($GUI2, "", $x2 + $iniread_12, $y2 + $iniread_14) 
        endif   
        if $p_win2 = 0 then 
            exit        
        elseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
            $x2 = $p_win2[0]
            $y2 = $p_win2[1]
            $x1 = $p_win2[0] - $p_win1[2] + ($xx + 4)
            $y1 = $y2 + ($ya + 25)
            WinMove($GUI1, "", $x1 + $iniread_13, $y1 + $iniread_15) 
        EndIf
EndFunc   ;==>_ToolbarDocked

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