Yes, of course this stutters, as you don't give Windows any chance to apply it. The core thing running in windows is multiple processes with each multiple threads and a management of what slices of time are assigned to which processes. If you want something to come into effect, you got to let it happen. There has to be time for the OS and grapics to do the Move.
The core thing making the progress bar smooth was to not allow more than 25 paint events to happen per second.
Wait is not a good thing to do, DOEVENTS is what is necessary.
You also still fail to see that the SCREEN or even the Windows DESKTOP needs a refresh to redraw the moved window in it.
If you do such a tight loop you don't give anything a chance to react. Most eveything you do in regard of changing a form position or position of objects within or text contained will only be queued in Windows event queueue, you got to give that a chance to work.
Do this:
Code:
FOR I = 1 TO 200
DOEVENTS
ThisForm.Move(I*4,I*4)
NEXT
Or to make this an animation going with about .02 seconds per frame:
Code:
DECLARE Sleep IN WIN32API integer nMilliseconds
thisform.Refresh
FOR I = 1 TO 200
_screen.cls()
DOEVENTS
Sleep(20)
ThisForm.Move(I*4,I*4)
NEXT
a) You don't need a refresh to let a moved form be drawn at its new position, but force a repaint of the _screen.
b) Wait Window is a really bad choice as itself creates a window (guess what it's named? wait window), even when you use "" as its display text you still go through all window creation, the form you animate is losing focus and later is reactivated, you cause it to repaint multiple times. For a short wait use Sleep(), if you only want to let a process sleep and use DOEVENTS most of the time you just want things to happen. Here I do both, as sleep alone doesn't trigger enough. In this case you better do DOEVENTS without the FORCE option, as you don't care about the whole windows events, only your own.
In regard of getting a smooth animation you'd need to bind _screen paint events and suppress them, if they happen too frequent, that'll make animations smoother.
Besides as I already proposed earlier calculating positions by passed time will give you a better repeatable animation style than doing things "as fast as they can be done". I understand you just do this to demo some unsmooth behaviour, but come on, don't do silly things to prove something, that doesn't make any point. Doing silly code makes silly things happen. First silly thing is doing something long running in a click event. You freeze the event queue because you yourself don't return from an event. This doesn't only suggest using DOEVENTs to cope with this, it's the only chance, no Wait Window will really help here. Click is an event and you don't put anything long running in there, you don't animate using a loop, but setting positions in a timer event, just one position of the whole animation, the loop is done by having a timer interval.
Besides all that, Foxpro isn't any animation software anyway, not even Windows itself. Animated windows are a WPF feature, not a winforms feature, never was, never will be. Rememember Win 3.1/3.11, how minimized forms where "resurrected" by drawing some lines indicating form growth and only finally drawing the form? To lead the users eye, that also is sufficient. If you want to force it, then do so, but then use something more modern than Foxpro or even than Windows.
Bye, Olaf.