Sign in to follow this  
Followers 0
momar33

Wiindow not maximizing all the way

3 posts in this topic

In the code below, if you hit the spell button to open a child window, then maximize the child window, then try to maximize the parent window, it doesn't maximize all the way.

I am sure it has something to do with my _UpdatChildGui function, specificly this line:

WinMove($child[$i], '', -4, -4, $array[2], ($array[3]-76))

Unfortunately i don't know why it is doing this.

Other ideas for resizing child guis are wlecome as well.

Thanks

Here is the code:

#include <GUIConstants.au3>
;#include <database.au3>
;#include <variables.au3>

Global $child[1000]
Global $spellEdit
Local $parentWidth = 800
Local $parentHeight = 500
Local $parentLeft = -1
Local $parentTop = -1
Local $toolBarWidth = $parentWidth
Local $toolBarHeight = 30
Local $toolBarLeft = 0
Local $toolBarTop = 0
Local $mainWidth = $parentWidth
Local $mainHeight = $parentHeight - 50
Local $mainLeft = 0
Local $mainTop = $toolBarHeight

;AutoItSetOption("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

Global $parentGui = GUICreate("Spell Inventory", $parentWidth, $parentHeight, $parentLeft, $parentTop, $WS_OVERLAPPEDWINDOW)
_CreateEvents()
GUISetState()

_CreateMenu()

_CreateToolbar($toolBarWidth, $toolBarHeight, $toolBarLeft, $toolBarTop)



Global $mainGui=GUICreate("mainGui", $mainWidth, $mainHeight, 0, 30, $WS_CHILD, Default, $parentGui)
GUISetState ()

While 1
    Sleep(10)
Wend

Func _Exit()
    ;MsgBox(0, "", "test2" & @GUI_WINHANDLE)
    ;MsgBox(0, "", WinGetHandle($child[$numChildGuis]))
    If @GUI_WINHANDLE = $parentGui Then
        ;GUISwitch($parentGui)
        GuiDelete()
        Exit
    ElseIf @GUI_WINHANDLE =  WinGetHandle($child[$numChildGuis]) Then
        ;MsgBox(0,"","test")
        GUISwitch(WinGetHandle($child[$numChildGuis]))
        GuiDelete()
        GUISetState(@SW_SHOW,$parentGui)
    EndIf
EndFunc

Func _MakeNewChild()
    Global $numChildGuis
    if $numChildGuis < 1000 then
;~         $gui[$x] = GUICreate("",200,90,100+$numChildGuis*5,100+$numChildGuis*5, BitOR($WS_POPUPWINDOW, $WS_CHILD),$WS_EX_TOOLWINDOW)
;~      ;$child = GUICreate("View Spells", 400, 350, 100, 0, BitOR($WS_OVERLAPPEDWINDOW, $WS_CHILD), Default, $mainGui)
;~         DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Gui[$x]), "hwnd", WinGetHandle($Main_GUI))
        
        $child[$numChildGuis] = GUICreate("View Spells", 400, 350, 100+$numChildGuis*5, 0+$numChildGuis*5, $WS_OVERLAPPEDWINDOW, Default, $mainGui)
        DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child[$numChildGuis]), "hwnd", WinGetHandle($mainGui))
        GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
        GUISetState()
        $numChildGuis = $numChildGuis +1
    EndIf
EndFunc

Func _CreateMenu()
    ;-----File Menu-----
    Global $fileMenu = GuiCtrlCreateMenu ("File")
    Global $importMI = GuiCtrlCreateMenuitem ("Import File",$filemenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$filemenu)
    Global $ppOptionsMenu = GuiCtrlCreateMenu ("Print Preview Options",$filemenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$filemenu)
    Global $exitMI = GuiCtrlCreateMenuitem ("Exit",$filemenu)

    ;-----Tools Menu-----
    Global $toolsMenu = GuiCtrlCreateMenu ("Tools")
    Global $manageSpellbooksMI = GuiCtrlCreateMenuitem ("Manage Spellbooks",$toolsMenu)
    Global $manageSchoolsMI = GuiCtrlCreateMenuitem ("Manage Schools",$toolsMenu)
    Global $manageSpellsMI = GuiCtrlCreateMenuitem ("Manage Spells",$toolsMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$toolsMenu)
    Global $manageScrollsMI = GuiCtrlCreateMenuitem ("Manage Scrolls",$toolsMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$toolsMenu)
    Global $searchMI = GuiCtrlCreateMenuitem ("Search",$toolsMenu)

    ;-----Window Menu-----
    Global $windowMenu = GuiCtrlCreateMenu ("Window")
    Global $tileMI = GuiCtrlCreateMenuitem ("Tile",$windowMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$windowMenu)
    Global $cascadeMI = GuiCtrlCreateMenuitem ("Cascade",$windowMenu)

    ;-----About Menu-----
    Global $aboutMenu = GuiCtrlCreateMenu ("About")
    Global $helpTopicsMI = GuiCtrlCreateMenuitem ("Help Topics",$aboutMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$aboutMenu)
    Global $aboutMI = GuiCtrlCreateMenuitem ("About SI",$aboutMenu)
EndFunc

Func _CreateToolbar($width, $height, $left, $top)
    Global $toolbar=GUICreate("toolbar", $width, $height, $left, $top, $WS_CHILD, Default, $parentGui)
    Global $viewSpell = GUICtrlCreateButton ("Spell", 0,0,50,20)
    GUICtrlSetOnEvent(-1, "_MakeNewChild")
    GUISetState ()
EndFunc

Func _CreateEvents()
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_RESIZED, "_UpdateChildGui")
    GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_UpdateChildGui")
    GUISetOnEvent($GUI_EVENT_RESTORE, "_UpdateChildGui")
EndFunc

Func _UpdateChildGui()
    Local $state
    Local $array = WinGetPos($parentGui)
    WinMove($mainGui, '',  0, 30, ($array[2]-8), ($array[3]-84))
    ConsoleWrite("--"&$child[0]&@CR)
    If $child[0] <> 0 then
        For $i = 0 to $numChildGuis step 1
            ConsoleWrite("----"&$i&@CR)
            $state = WinGetState($child[$i])
            If BitAnd($state, 32) Then  
                WinMove($child[$i], '',  -4, -4, $array[2], ($array[3]-76))
            EndIf
        Next
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You were right the problem is with you _UpdatChildGui function, but is not with WinMove() the problem is with the For...Next loop.

you are using

For $i = 0 to $numChildGuis step 1

instead of

For $i = 0 to $numChildGuis - 1 step 1

The For...Next was looping one time too many :whistle:

Edited by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Awesome. Thanks man!

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