[DUG] Updating a property's memory address doesn't cause a redraw
Paul Lyons
p.lyons at paradise.net.nz
Tue May 28 01:02:49 NZST 2013
Hi there
I've written a generalised interpolator that gradually changes the
value of a property such as panel1.width from startValue to endValue
over a given period. This gives me a general way of animating
movements and positions of interface components.
I tell the interpolator the address of the property, the start and
finish values:
interpolater.addProperty(addr(panel1.width), panel1.width, panel1.width+100);
As you can see, the property is passed as a pointer. The interpolator
goes into a loop for whatever time duration I've specified, updating
the property pro rata on each iteration. However, although the memory
location where the property is stored does genuinely get updated, it
seems that Delphi isn't aware that updating that memory location
should generate a redraw event for the panel. I can force a redraw by
putting a pair of net-null-effect statements like this
panel1.width := panel1.width - 1;
panel1.width := panel1.width + 1;
into the loop, and then the interpolation works fine, but the goal
was to avoid having to tell interpolator anything about the component
that needs to be redrawn other than the memory location of its property.
Things that don't work include
application.processmessages
panel1.update
panel1.repaint
panel1.invalidate
panel1.width := panel1.width
Optimisation is not turned on.
It seems as though even if you force Delphi to redraw a component, it
won't check the property values unless it knows that at least one
property has been updated. So the problem is, having updated a memory
location, how do I tell the component that its property has been updated?
Thanks
Paul
More information about the Delphi
mailing list