Smoothly closing a window?

Hi,
I want to be able to close a window smoothly by making it slowly get smaller from all sides.
I’ve given this a lot of thought and the closest I have come is putting this code in a timer that’s activated when a close button is clicked:

if frmLogin.Width > 25 then frmLogin.Width=frmLogin.Width-16 frmLogin.Left=frmLogin.Left+8 frmLogin.Height=frmLogin.Height-12 frmLogin.Top=frmLogin.Top+6 else quit end

This works as I want but it’s not smooth whatsoever.
I can make it smooth when only changing the Width and Height but it only gets smaller from the right and bottom sides, and also it’s too slow because I cannot make the timer’s period less than 1 (or is there a way?).

Is there another way to smoothly close a window? It’s like tweening, if that’s a known thing.

Thanks for your help.

Have you tried adjusting the left and right values 1/2 of what you are decreasing the width and height. That, I would think, would have it appear to shrinking in from all four sides

You need to modify the bounds of the window instead of each left/width/height/top property directly. Modifying each directly causes the window to be redrawn 4 times producing the jittery effect. If you modify the bounds it will be smooth and only refresh once. Try this:

Static mrect as REALbasic.rect if self.Width > 25 and self.Height >25 then mrect = self.Bounds mrect.Width = mrect.Width - 16 mrect.Height = mrect.Height - 12 mrect.left = mrect.Left + 8 mrect.Top = mrect.Top + 6 self.Bounds = mrect else Quit end if

I see why it jittered now, thanks.
It works perfectly, thank you very much!

That’s what I was already doing haha.
But thanks for the reply!