|Auto resizing button's on full screen|
|Started by Timothy V, Aug., 01 2022 1:23 PM - 2 replies|
Posted on August, 01 2022 - 1:23 PM
First of all, i'm new to Windev and i'm trying to find my way in it.
I struggle on my first little problem.
I'm making a little app with 9 buttons on it. They have to be a fluid width and high. I'm trying to use Anchors for this.
But it is just not working out for me.
I'm able to use fluid width or fluid heigh seperatly, then everything looks ok. But if try to do both at the same time, the buttons are overlapping.
See my examples with width, height and then the messed up all.
I hope somebody here could help me into the righ direction.
Posted on August, 04 2022 - 2:07 PM
i was also not able to get it work using anchors, i would guess, one corner of the control is allways fixed (anchored) to a border or corner.
as workaround you can do this by coding like:
in the global declaration section of your place something like this
distanceBorderTop = 20
distanceBorderBottom = 20
distanceBorderLeft = 4
distanceBorderRight = 4
SpaceBetweenButtons = 3
DistanceHorz = distanceBorderLeft + distanceBorderRight + (2 * SpaceBetweenButtons)
DistanceVert = distanceBorderTop + distanceBorderBottom + (2 * SpaceBetweenButtons)
ST_Button is structure
btn is Control
garrButtons is array [3,3] of ST_Button
garrButtons[1,1].btn <- BTN_TopLeft
garrButtons[1,2].btn <- BTN_TopCenter
garrButtons[1,3].btn <- BTN_TopRight
garrButtons[2,1].btn <- BTN_CenterLeft
garrButtons[2,2].btn <- BTN_CenterCenter
garrButtons[2,3].btn <- BTN_CenterRight
garrButtons[3,1].btn <- BTN_BottomLeft
garrButtons[3,2].btn <- BTN_BottomCenter
garrButtons[3,3].btn <- BTN_BottomRight
Create also a procedure in your window like
btnWidth is int = (WinInWidth(WIN_Main) - DistanceHorz) / 3
btnHeight is int = (WinInHeight(WIN_Main) - DistanceVert) / 3
FOR x = 1 TO 3
FOR y = 1 TO 3
garrButtons[x,y].btn..Width = btnWidth
garrButtons[x,y].btn..Height = btnHeight
garrButtons[x,y].btn..X = distanceBorderLeft + ((x-1) * SpaceBetweenButtons) + ((x-1)*btnWidth)
garrButtons[x,y].btn..Y = distanceBorderTop + ((y-1) * SpaceBetweenButtons) + ((y-1)*btnHeight)
in the end of initialization section of your window
add the resizing-event to your window and place there also
thats all, maybe there is a better solution
Posted on August, 05 2022 - 12:57 PM
Was able to get it working with your scripts!