Resizing

I had the following in the Resized event which seemed to work to an extent

PlayerWnd.Height = PlayerWnd.Width *.6

but when I changed it to the following it now crashes when I drag the window to its max width

PlayerWnd.Height = PlayerWnd.Width *.6
if playerwnd.Height > screen(0).AvailableHeight then
PlayerWnd.Height = screen(0).AvailableHeight
end if

I can’t see why though??

RECURSION
you change PlayerWindHeight
then check if it is greater than Screen Height
if it is you change it again (which call resize, which in turn changes it to Width*.6 again

Its a never ending cycle

Yes, it’s an endless loop. But that should just make the app unresponsive, not make it crash.

Martin, is it really a crash, or just being non-responsive and having to kill it?

Either way, you should change your code to something like this:

PlayerWnd.Height = Min(screen(0).AvailableHeight, PlayerWnd.Width *.6)

Also, why is this in the Targets channel?

[quote=427681:@Jay Madren]Yes, it’s an endless loop. But that should just make the app unresponsive, not make it crash.

[/quote]
and endless loop and a recursive loop are not the same
and endless loop stays inside the same scope and doesn’t consume stack space.
a recursive loop does, and as soon as all the stack space is consume the app will crash.

while true<>false
... this is an endless loop
wend
function test()
    test() // this is a recursive loop
end function

[quote=427683:@Dave S]a recursive loop does, and as soon as all the stack space is consume the app will crash.[/quote]I was thinking that since the code does not call the Resized event directly, and (I thought) the new event wouldn’t be fired until the current event exited, that it wouldn’t create a recursion. But I just tested it and it does. So you’re correct, this is a recursive loop that will crash the app.

But my suggestion will avoid that.

Also, Martin, if you are wanting to enforce a certain aspect ratio, then you’ll need to add more logic to what I wrote to maintain that ratio while keeping the window from expanding beyond the screen. But you will still need to it in a way that doesn’t cause the recursion.

Sorry team I didnt realize I created 2 threads. I will check and revert. Cheers Martin