Paul, Hi. You cannot treat Delphi properties as simple pointers to data. Properties are always accessed through setter and getter methods, either explicitly defined or implicitly through compiler magic. The best way to achieve what you are doing is to pass your routine a component reference and the name of the property. Use RTTI to set the value - Google this, there are plenty of code examples out there. Keep in mind also setting properties in most cases only invalidates the component. You will need to explicitly refresh it to force the redraw.
Regards, Dennis. -----Original Message----- From: Paul Lyons Sent: Tuesday, May 28, 2013 1:02 AM To: [email protected] Subject: [DUG] Updating a property's memory address doesn't cause a redraw 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 _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
