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 post
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 post
Share on other sites

thanks jdelaney finally this works :D

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 post
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 post
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 post
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 post
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 post
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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AntS
      Help! The mouse clicks I'm sending to a control on a dialog box produce no response.
      The dialog box in question handles advanced display properties. The tab page my script interacts with is created by Trident Microsystems. It allows the user to enhance or attenuate the screen's RGB values. (See image.) My script automates the process of changing these in order to adjust the screen's hue or, when the red, green and blue values are all the same, the brightness.
      Producing a script to change the brightness has been quite straightforward. I use ControlClick() to send a mouse click to one of the trackbars on the right of the tab page. By default, they're linked and so move as one. The difficulty I'm having however is in automating the process when the desired red, green and blue values aren't the same as each other.
      Ordinarily, there are three ways of doing this: 
      (1) clear the Link check box to unlink the three trackbars then either click on each trackbar or drag their sliders,
      (2) clear the Link tick-box then for each colour, click on the corresponding trackbar slider (to select it) then click on a point on the graph, and
      (3) click on the Load button to open an Open dialog box and load a preset (stored as a .gam file).
      However, when ControlClick() is used to clear the Link check box or to push the Load button, nothing happens. Making the dialog box the active window makes no difference.
      The AutoIt Window Info tool indicates that the Reload a Bitmap, Save, Load and Reset buttons, the Link check box and the graph are all the same control. (See other images.) In fact, it there are only four controls on the page: the tab page, which is an instance of a SysTabControl32 class, and the three trackbars, each of which is an instance of the TridentTrackBar class. (Am unsure whether the SysTabControl32 class is a Windows or third-party control.)
      What's the solution?
      Note that the MouseClick() function—as opposed to ControlClick()—does work, but having AutoIt commandeer the screen pointer isn't an acceptable solution.
      For the sake of completeness, here's the relevant code fragment for the Link check box. 
      ;unlink trackbars WinActivate("(Multiple Monitors)") ControlClick("(Multiple Monitors)", "", 12320, "left", 1, 211, 252)  



    • By nacerbaaziz
      hello guys, please i need your help
      am trying to work with CreateWindowEx api, i created the window with it controls, also i setup the call back function
      i'am using WinMSGLoop to focus with the keyboard.
      here i have a problem, i hope that you can help me.
      on the controls i used the UDF that comme with the autoit, such as _GUIButton_Create, _GUIListBox_Create....
      but i can't find a STATIC control UDF, for that i used this

      local $h_ssrvlbl = _WinAPI_CreateWindowEx(0, "STATIC", "الخادم", BitOr($WS_VISIBLE, $WS_CHILD, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN), 250, 10, 100, 20, $hWnd)
      as you can see here, there is an arabic text, so here is the problem, the arabic text isn't show normally, what is the problem here?
      also i have  an other question about keyboard focus, when i used WinMSGLoop, it worked, but if i press alt+tab to switch windows or focus an other window and return back to my window, the focus of control is kill.
      can any one help me to solve that please?
      my code will be as file here with the include files
      i hope can any one help me here
      thanks in advance
       
      speed Test win.zip
    • By TheSaint
      I like and have been using TeraCopy, a third party program, for many years. Mostly it is a great program, but it does have some issues. On Windows XP for instance, Thumbs.db files could often hold up a copy or move process until the user manually responded to the error prompt. Some other issues I discuss below.
      PLEASE NOTE - I am not related to or affiliated in any way with the 3rd party TeraCopy program developers.
      ALSO NOTE - I myself have only tested TeraCopy Cure at this point, on Windows 7 (32 bit), and only with the free version of TeraCopy 2.27.
      This program, TeraCopy Cure, is related to another one of my TeraCopy assistant programs, TeraCopy Timer, but aims at being simpler and quicker to use ... if lacking its more advanced features.
      TeraCopy Cure is a frontend for TeraCopy and sets out to make up for its flaws and limitations.
      One of those flaws is queuing order, and the limitation relates to a same destination issue.
      You would think that queue order would be the same as add order, but that is not the case, and if you are doing a mix of COPY and MOVE then the COPY process could easily fail. It could fail with some source items, even if the  COPY process has already started before the same source MOVE process begins ... especially if the destination folder is on the source drive ... only the currently copying file is locked to that process.
      If you drag and drop another source for a same destination as an existing or impending COPY or MOVE process, then usually TeraCopy nicely adds it for you to that existing job. However, you might wish to avoid that, or it might occur during the testing phase of that active process, and then not be properly processed etc. But you are not given a choice and it just gets added.
       
           
      HOW TO USE
      See the right-click menu of the 'Batch List' (lowest field) and the right-click menu of the Tree field, for some useful options.
      (1) If desired, enable 'Auto Start'. NOTE - Even if enabled, this can be bypassed.
      (2) Set the destination folder, either by browsing on the tree or by dragging a folder to the Destination input field or label. Right-clicking on a folder in Explorer will also work, if enabled. The destination folder path will also show in the Tree if that right-click option is enabled.
      (3) Then drag & drop source file or folder onto one of three five areas - Folder (Drive) Tree field, or COPY or MOVE buttons ... this now also includes the source input and label.
      NOTE - If the Folder (Drive) Tree field is used, then you will additionally need to click either the COPY or MOVE button, to have that job added to the Batch List ... but this avoids 'Auto Start' if it is enabled. Drag & dropping to the buttons instead, saves on clicking, but starts the first job etc immediately if 'Auto Start' is enabled.
      (4) If needed and ready, click the START button to run the first job and those that follow.
      More information is included in program and in the NOTES etc sections below.
         
      WARNING - Depending on the amount of content on your destination drive, and folder level depth, and the speed of your PC, display of the full path in the Folder (Drive) Tree can take a while to show ... if you have that (right-click) option enabled ... it isn't by default. I found this feature quite tricky to get right, and I'm still not 100% sure it is now full-proof.
      TeraCopy Cure v1.5.zip  (source is included)
      TeraCopy Cure v1.6.zip  (source is included)
      NOTES
      UPDATES INFORMATION
      OLDER DOWNLOADS
       
    • By kellariluukku
      Hey.
      Is there anything that does the same thing as this?
       
      Namely I'm talking about detecting when something has changed on screen.
      The FastFind library is crashing without any errors after running:
      FFSnapShot($left, $top, $right, $bottom, 0) FFSnapShot($left, $top, $right, $bottom, 1) $diff = FFLocalizeChanges(0, 1) And then trying to overwritite the old snapshot (0 or 1).
      If I use always different snapshot numbers its using too much memory and will eventually crash my pc.
      I tried downloading older versions but they're not working and the author is inactive.
       
      It takes 2 snapshots and compares them returning the area that has changed very quickly (left, top, right ,bottom).
      Can anyone help me do this?
      Looping PixelGetColor would require a bunch of extra code to my purpose and its not as efficient...
       
      Thanks
       
       
    • By Cengokill
      Hi everyone,
      I have created a ListView that is in a tab, and I want to display an image in that tab, with the ListView on top.
      However, the image still appears on top of my ListView.
      If I remove the tabs everything works. 
      I looked at the autoit documentation and the <GuiListView.au3> documentation , I can't figure out how to display a background image, and put on top a ListView, inside a tab. 😥
      Here is the code:
      Opt("GUIOnEventMode", 1) $Form1 = GUICreate($Titre, 700, 627, $Form1Width, $Form1Height); main window $tabulation = GUICtrlCreateTab(148,0,700,580); creating tabs $tab1=GUICtrlCreateTabItem("Tab 1"); first tab GUICtrlSetState(-1, $GUI_SHOW); this tab is selected by default $Pic1 = GUICtrlCreatePic("image.jpg", 0, 30, 700, 627) GUICtrlSetState(-1, $GUI_DISABLE). $idListview = GUICtrlCreateListView("list 1|list 2|list 3", 200, 50, 390, 200) GUISetState(@SW_SHOW) While 1     Sleep(100) WEnd Thank you in advance.

×
×
  • Create New...