TheDcoder Posted May 19, 2017 Share Posted May 19, 2017 Hello, I am just getting started with making GUIs manually, by hand, without any tools/builders to assist me. I have discovered something strange: I am trying to fit a control (take an Edit control for example) with equal spacing on every side of the control... Something like this: I did something weird to make this happen, first I choose a coordinate for the X and Y for the Edit control, that is 4 in this GUI. I tried to remove 4 from the control's height and and width to make it space even at the right side and bottom of the GUI... but this happen when I tried that: As you can see, the Edit control is hugging the GUI frame at the bottom and right sides of the GUI... Very strange huh? I mean, it's a perfect 0 pixel gap! So I tried to double the coordinates and it worked. The GUI was evenly spaced on all side like in the first picture. This is my code: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) Local Const $eiGuiWidth = 580, $eiGuiHeight = 280 Local Const $eiCoord = 4 Global $g_hLogGUI = GUICreate("Test", $eiGuiWidth, $eiGuiHeight, Default, Default, $WS_OVERLAPPEDWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_WindowExit") ;GUICtrlCreateGroup("Test Group", $eiCoord, $eiCoord, $eiGuiWidth - ($eiCoord * 2), $eiGuiHeight - ($eiCoord * 2)) GUICtrlCreateEdit("", $eiCoord, $eiCoord, $eiGuiWidth - ($eiCoord * 2), $eiGuiHeight - ($eiCoord * 2)) GUISetState(@SW_SHOW, $g_hLogGUI) ; Make the GUI visible While True Sleep(1000) WEnd Func GUI_WindowExit() Exit EndFunc You can adjust $eiCoord and the edit control will always be spaced evenly... I wonder why? any explanations? Thanks in Advance P.S Sorry for the very descriptive title EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2017 Share Posted May 19, 2017 (edited) Its a border style. You can get rid of it by changing the style. Look at control/win styles - particularly extended styles. Edited May 19, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2017 Share Posted May 19, 2017 (edited) Sorry I seem to have misunderstood your question. I get a 4 pixel gap on all four sides of the edit using your code. 1 hour ago, TheDcoder said: You can adjust $eiCoord and the edit control will always be spaced evenly... I wonder why? Because the width and height are calculated accordingly : $eiGuiWidth - ($eiCoord * 2). You have to reduce the width of the edit for both the left and the right side ==> ($eiCoord * 2). Two gaps - right! Edited May 19, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheDcoder Posted May 19, 2017 Author Share Posted May 19, 2017 @czardas I was expressing my thoughts in the form of that question, sorry if I was not clear enough. I know that it will always fit because $eiCoord is multiplied to 2, but why? why does it need the "gap" 2 times? That was my question . I have tried using the $WS_POPUP style and same result... minus the window border, so I think that is not the issue... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) Local Const $eiGuiWidth = 580, $eiGuiHeight = 280 Local Const $eiCoord = 10 Global $g_hLogGUI = GUICreate("Test", $eiGuiWidth, $eiGuiHeight, Default, Default, $WS_POPUP) GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_WindowExit") ;GUICtrlCreateGroup("Test Group", $eiCoord, $eiCoord, $eiGuiWidth - ($eiCoord * 2), $eiGuiHeight - ($eiCoord * 2)) GUICtrlCreateEdit("", $eiCoord, $eiCoord, $eiGuiWidth - ($eiCoord * 2), $eiGuiHeight - ($eiCoord * 2)) GUISetState(@SW_SHOW, $g_hLogGUI) ; Make the GUI visible While True Sleep(1000) WEnd Func GUI_WindowExit() Exit EndFunc EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2017 Share Posted May 19, 2017 (edited) It's because you are referencing the width of the GUI to set the width of the Edit control. The horizontal dimensions are as follows: <=4=>| EDIT |<=4=> <===GUI Width ===> C'mon, get with it. Edited May 19, 2017 by czardas TheDcoder 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
TheDcoder Posted May 19, 2017 Author Share Posted May 19, 2017 28 minutes ago, czardas said: C'mon, get with it. Thanks for the ASCII Drawing P.S I am not the one in the facepalm photo czardas 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
czardas Posted May 19, 2017 Share Posted May 19, 2017 I always drink a cup of coffee at times like this. TheDcoder 1 operator64 ArrayWorkshop 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