Jump to content

Resizing a window with WinMove shifts controls


Recommended Posts

With the following test code below, I noticed that resizing a window with WinMove() shifts controls on the windows from their previous positions. Is this normal behavior? If yes, How can I prevbent the existing controls from moving?

#include <GUIConstantsEx.au3>

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

GUICreate("Test", 220, 200)

GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")

GUICtrlCreateLabel("A", 20, 50)

GUICtrlCreateLabel("B", 20, 70)

GUICtrlCreateLabel("C", 20, 90)

$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)

GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1

Sleep(1000)

WEnd

Func close_button ()

GUIDelete()

Exit

Endfunc

Func resize_button ()

$pos_ar = WinGetPos("[active]") ;Get current window x, y

WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)

Endfunc

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Link to comment
Share on other sites

With the following test code below, I noticed that resizing a window with WinMove() shifts controls on the windows from their previous positions. Is this normal behavior? If yes, How can I prevbent the existing controls from moving?

#include <GUIConstantsEx.au3>

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

GUICreate("Test", 220, 200)

GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")

GUICtrlCreateLabel("A", 20, 50)

GUICtrlCreateLabel("B", 20, 70)

GUICtrlCreateLabel("C", 20, 90)

$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)

GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1

Sleep(1000)

WEnd

Func close_button ()

GUIDelete()

Exit

Endfunc

Func resize_button ()

$pos_ar = WinGetPos("[active]") ;Get current window x, y

WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)

Endfunc

It`s not the best example but idea is to prevent that labels do not move.

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1); Change to OnEvent mode

GUICreate("Test", 220, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")
Global $LABEL[4]
Global $TEXT[4] = ["","A","B","C"]
Global $TOP = 30

For $INDEX = 1 To 3
$TOP = $TOP + 20
$LABEL[$INDEX] = GUICtrlCreateLabel($TEXT[$INDEX], 20,$TOP)
Next


$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)
GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1
Sleep(1000)
WEnd

Func close_button ()
GUIDelete()
Exit
Endfunc

Func resize_button ()
$pos_ar = WinGetPos("[active]");Get current window x, y
WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)
$TOP = 30
For $INDEX = 1 To 3
    $TOP = $TOP + 20
    GUICtrlDelete($LABEL[$INDEX])
    $LABEL[$INDEX] = GUICtrlCreateLabel($TEXT[$INDEX], 20,$TOP)
Next
Endfunc

When the words fail... music speaks.

Link to comment
Share on other sites

With the following test code below, I noticed that resizing a window with WinMove() shifts controls on the windows from their previous positions. Is this normal behavior? If yes, How can I prevbent the existing controls from moving?

#include <GUIConstantsEx.au3>

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

GUICreate("Test", 220, 200)

GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")

GUICtrlCreateLabel("A", 20, 50)

GUICtrlCreateLabel("B", 20, 70)

GUICtrlCreateLabel("C", 20, 90)

$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)

GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1

Sleep(1000)

WEnd

Func close_button ()

GUIDelete()

Exit

Endfunc

Func resize_button ()

$pos_ar = WinGetPos("[active]") ;Get current window x, y

WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)

Endfunc

GUICtrlSetResizing() is your friend!

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1); Change to OnEvent mode

GUICreate("Test", 220, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")

GUICtrlCreateLabel("A", 20, 50)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlCreateLabel("B", 20, 70)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlCreateLabel("C", 20, 90)
GUICtrlSetResizing (-1, $GUI_DOCKALL)

$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)
GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1
Sleep(1000)
WEnd

Func close_button ()
GUIDelete()
Exit
Endfunc

Func resize_button ()
$pos_ar = WinGetPos("[active]");Get current window x, y
WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)
Endfunc
Link to comment
Share on other sites

GUICtrlSetResizing() is your friend!

#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1); Change to OnEvent mode

GUICreate("Test", 220, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "close_button")

GUICtrlCreateLabel("A", 20, 50)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlCreateLabel("B", 20, 70)
GUICtrlSetResizing (-1, $GUI_DOCKALL)
GUICtrlCreateLabel("C", 20, 90)
GUICtrlSetResizing (-1, $GUI_DOCKALL)

$button1 = GUICtrlCreateButton("Resize", 20, 130, 60)
GUICtrlSetOnEvent($button1, "resize_button")

GUISetState()

While 1
Sleep(1000)
WEnd

Func close_button ()
GUIDelete()
Exit
Endfunc

Func resize_button ()
$pos_ar = WinGetPos("[active]");Get current window x, y
WinMove ( "Test", "", $pos_ar[0], $pos_ar[1], 220, 400)
Endfunc

Thanks for the information! My solution was:

Opt("GUIResizeMode", 802) ;Disable auto-resizing of ALL controls when window is resized

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Link to comment
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
 Share

  • Recently Browsing   0 members

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