Jump to content

[Solved] Cannot resize a window without moving it on tab change


Recommended Posts

Hi everyone :)

I have a problem resizing a window when a other tab is selected, the problem is not in resizing it but to keep the windows in the same position

here's a example:

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 386, 274)
$Tab1 = GUICtrlCreateTab(0, 0, 385, 273)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
GUICtrlSetState(-1, $GUI_SHOW)
$input1 = GUICtrlCreateInput("Click in here", 60, 34, 100, 22)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Tab1
$pos = WinGetCaretPos()
If GUICtrlRead($Tab1) = 0 Then
WinMove($Form1, "", $pos[0] - 3, $pos[1] - 25, 386, 274)
GUICtrlSetPos($Tab1, -1, -1, 386, 274)
ElseIf GUICtrlRead($Tab1) = 1 Then
WinMove($Form1, "", $pos[0] - 3, $pos[1] - 25, 276, 300)
GUICtrlSetPos($Tab1, -1, -1, 276, 300)
EndIf
EndSwitch
WEnd

As you can see/test, if you change tab without clicking in a control (input1) the window will be resized without moving, but if you click/input in a control it starts moving

Any tips?

Edited by DiOgO

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

use wingetpos:

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 386, 274)
$Tab1 = GUICtrlCreateTab(0, 0, 385, 273)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
GUICtrlSetState(-1, $GUI_SHOW)
$input1 = GUICtrlCreateInput("Click in here", 60, 34, 100, 22)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Tab1
   $pos = WinGetPos($Form1)
   If GUICtrlRead($Tab1) = 0 Then
    WinMove($Form1, "", $pos[0], $pos[1], 386, 274)
    GUICtrlSetPos($Tab1, -1, -1, 386, 274)
   ElseIf GUICtrlRead($Tab1) = 1 Then
    WinMove($Form1, "", $pos[0], $pos[1], 276, 300)
    GUICtrlSetPos($Tab1, -1, -1, 276, 300)
   EndIf
 EndSwitch
WEnd

edit: made it "tidy"

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

sorry for bringing this up, what could be the reasons for winmove() cannot resize? (handle and parameters all correct, I test it in a gui without any stuff)

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

  • Moderators

DiOgO,

You have been here long enough to know we need to see some code which demonstrates the problem, otherwise we cannot really help you. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

DiOgO,

You have been here long enough to know we need to see some code which demonstrates the problem, otherwise we cannot really help you. ;)

M23

okey :)

I tried to use just a variable to set expand or collapse and now works :D

can you tell me de difference between WinGetPos() window size and GuiCreate()? I set a size on GUICreate and WinGetPos gives me another, is due the fact I have a Top Menu? (the one created with GUICtrlCreateMenu())

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

  • Moderators

DiOgO,

can you tell me de difference between WinGetPos() window size and GuiCreate()?

That one is easy! :D

GUICreate creates a GUI with a client area of the requested size - the actual GUI is often larger because it usually has borders and a title bar. WinGetPos tells you the size of the whole GUI - but WinGetClientSize will return the originally requested values: ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

GUISetState()

$aPos = WinGetPos($hGUI)
$aClient = WinGetClientSize($hGUI)

MsgBox(0, "Sizes", "Requested: 500 x 500" & @CRLF & "Full GUI: " & $aPos[2] & " x " & $aPos[3] & @CRLF & "Client: " & $aClient[0] & " x " & $aClient[1])

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

All clear now? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

DiOgO,

That one is easy! :D

GUICreate creates a GUI with a client area of the requested size - the actual GUI is often larger because it usually has borders and a title bar. WinGetPos tells you the size of the whole GUI - but WinGetClientSize will return the originally requested values: ;)

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

GUISetState()

$aPos = WinGetPos($hGUI)
$aClient = WinGetClientSize($hGUI)

MsgBox(0, "Sizes", "Requested: 500 x 500" & @CRLF & "Full GUI: " & $aPos[2] & " x " & $aPos[3] & @CRLF & "Client: " & $aClient[0] & " x " & $aClient[1])

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

All clear now? :)

M23

wow thanks Melba again :D now no problems in using the same size as the guicreate :)

I didn't know about WinGetClientSize() function >_<

Edited by DiOgO

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

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

×
×
  • Create New...