Repositioning ContainerControls in resize events.

I have four container controls on my window and when the window resizes I want to be able to move the top left and adjust the height of each control, but it is messing up!

The top container controls top left is anchored and the bottom container controls bottom right is anchored bottom right.
The others are anchored top, left.

This is the window resized event:

[code]dim t as single
dim b as single
const gap as single = 20
dim wh, h as single

t = C1.top // Top of top control.
b = top + height // Bottom of the ‘window’

wh = (b - t + 1) // Height of all controls.
h = (wh / 4) - (4 * gap) // Height of each control.

C1.Height = h
t = t + h + gap

C2.top = t
C2.Height = h
t = t + h + gap

C3.Top = t
C3.Height = h
t = t + h + gap

C4.Top = t
C4.Height = h[/code]

This behaves very oddly in the resized event… or resizing or paint…
What am I doing wrong?
Is it that I must do something with the resize events of each control as well?

you didn’t define what “oddly” means… but I think you may want to change

b = top + height // Bottom of the ‘window’
to
b=height

Top+Height is the bottom of the window relative to the SCREEN. for positioning controls you want it relative to the WINDOW
ie. the top/left of the Window is considered 0,0 ,

A screenshot of what you are doing and what you want to do instead would help.

The containers are stacked on top of each other, correct?

Thank you Dave.
Indeed I wasn’t sure if my co-ordinates were reletive to the screen, the window etc.
Sometimes odd behaviour if explained points right to the problem… :wink:

[quote=418336:@Dave S]you didn’t define what “oddly” means… but I think you may want to change

b = top + height // Bottom of the ‘window’
to
b=height

Top+Height is the bottom of the window relative to the SCREEN. for positioning controls you want it relative to the WINDOW
ie. the top/left of the Window is considered 0,0 ,[/quote]