Capel Posted September 11, 2009 Share Posted September 11, 2009 I have created a simple form and put some buttons on it. One of the buttons resizes the form using the WinMove function. When I click the button, it moves all the buttons down by 23 in the Y direction. Why does it do this and how can I avoid it? I don't want to have to reposition all the controls on my form when I resize it... Link to comment Share on other sites More sharing options...
ctyankeeinok Posted September 11, 2009 Share Posted September 11, 2009 code sample? Link to comment Share on other sites More sharing options...
Capel Posted September 11, 2009 Author Share Posted September 11, 2009 (edited) quote name='ctyankeeinok' date='11 September 2009 - 12:51 PM' timestamp='1252687872' post='725830'] code sample? Edited September 11, 2009 by Capel Link to comment Share on other sites More sharing options...
Yashied Posted September 11, 2009 Share Posted September 11, 2009 (edited) Add the following line: GUICtrlSetResizing($Button1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) Edited September 11, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Capel Posted September 11, 2009 Author Share Posted September 11, 2009 Add the following line: GUICtrlSetResizing($Button1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) Thanks Yashied, this fixed the button moving around, but explain why the form height goes to 0 when i click the button a second time. WinMove("Form2", "", 302, 218, 413, 36) The form was created with a height of 36, but it seems like WinMove is not accounting for the height of the title bar. Link to comment Share on other sites More sharing options...
Yashied Posted September 11, 2009 Share Posted September 11, 2009 (edited) Thanks Yashied, this fixed the button moving around, but explain why the form height goes to 0 when i click the button a second time. WinMove("Form2", "", 302, 218, 413, 36) The form was created with a height of 36, but it seems like WinMove is not accounting for the height of the title bar. When you change the size of the window by WinMove() function you missed the title and borders. #Include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global $dW = 2 * _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Global $dH = 2 * _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) + _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $blOptionOut = False $Form2 = GUICreate("Form2", 413, 36, 302, 218) $Button1 = GUICtrlCreateButton("Button1", 4, 4, 77, 25) GUICtrlSetResizing($Button1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 resize() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func resize() $Pos = WinGetPos($Form2) If $blOptionOut Then WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 36 + $dH) $blOptionOut = False Else WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 197 + $dH) $blOptionOut = True EndIf EndFunc ;==>resize EDIT: Code Edited September 11, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Capel Posted September 11, 2009 Author Share Posted September 11, 2009 Thanks Yashied, that did it. Link to comment Share on other sites More sharing options...
Capel Posted September 14, 2009 Author Share Posted September 14, 2009 When you change the size of the window by WinMove() function you missed the title and borders. #Include <GUIConstantsEx.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Global $dW = 2 * _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) Global $dH = 2 * _WinAPI_GetSystemMetrics($SM_CXDLGFRAME) + _WinAPI_GetSystemMetrics($SM_CYCAPTION) Global $blOptionOut = False $Form2 = GUICreate("Form2", 413, 36, 302, 218) $Button1 = GUICtrlCreateButton("Button1", 4, 4, 77, 25) GUICtrlSetResizing($Button1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 resize() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func resize() $Pos = WinGetPos($Form2) If $blOptionOut Then WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 36 + $dH) $blOptionOut = False Else WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 197 + $dH) $blOptionOut = True EndIf EndFunc ;==>resize EDIT: Code So here is another strange thing. If I add the following line of code in the resize() function: ControlMove("", "", $Button1, 4, 4, 35, 25) in order to change the width of the button. Func resize() $Pos = WinGetPos($Form2) If $blOptionOut Then WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 36 + $dH) $blOptionOut = False Else WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 197 + $dH) ControlMove("", "", $Button1, 4, 4, 35, 25) $blOptionOut = True EndIf EndFunc Why does it reset the width of the button when I toggle it even though I have not told AutoIT to do this? The WinMove obviously resets the width of the button back to the original width! I want the width to stay smaller after I press it once... Link to comment Share on other sites More sharing options...
smashly Posted September 14, 2009 Share Posted September 14, 2009 Hi, use GUICtrlSetResizing() on the control after resizing itFunc resize() $Pos = WinGetPos($Form2) If $blOptionOut Then WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 36 + $dH) $blOptionOut = False Else WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 197 + $dH) ControlMove($Form2, "", $Button1, 4, 4, 35, 25) GUICtrlSetResizing($Button1, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKSIZE)) $blOptionOut = True EndIf EndFunc Cheers Link to comment Share on other sites More sharing options...
Capel Posted September 15, 2009 Author Share Posted September 15, 2009 So do I need to call GUICtrlSetResizing for every control on the form after every WinMove? Link to comment Share on other sites More sharing options...
smashly Posted September 15, 2009 Share Posted September 15, 2009 (edited) Not really, but it also depends on what your after. You'll need to experiment and see for your self. Edited September 15, 2009 by smashly Link to comment Share on other sites More sharing options...
Yashied Posted September 15, 2009 Share Posted September 15, 2009 Capel and Smashly, what's wrong with GUICtrlSetPos() ?Func resize() $Pos = WinGetPos($Form2) If $blOptionOut Then WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 36 + $dH) $blOptionOut = False Else ConsoleWrite('!' & @CR) WinMove($Form2, "", $Pos[0], $Pos[1], 413 + $dW, 197 + $dH) GUICtrlSetPos($Button1, 4, 4, 35, 25) ; ControlMove("", "", $Button1, 4, 4, 35, 25) $blOptionOut = True EndIf EndFunc ;==>resize My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Capel Posted September 15, 2009 Author Share Posted September 15, 2009 Yashied,What is the difference between the two other than how you reference the control? Do I still need to call GUICtrlSetResizing after every WinMove using GUICtrlSetPos? Link to comment Share on other sites More sharing options...
Yashied Posted September 15, 2009 Share Posted September 15, 2009 What is the difference between the two other than how you reference the control?GUICtrlSetPos() works with AutoIt controls only and designed for it.Do I still need to call GUICtrlSetResizing after every WinMove using GUICtrlSetPos?No. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now