[Home] [Puzzles & Projects] [Delphi Techniques] [Math Topics] [Library] [Utilities]
I am currently (January, 2008) exploring the feasibility of switching the compiler used for DFF programs from Delphi Version 5 to the more recent (and free) Turbo Delphi Explorer version. One significant difference is the lack of a TSpinEdit control in Turbo Delphi. Since I have used TSpinEdit in many programs here, we need an alternative way to provide the same function .
TDFFSpinEdit is my attempt to create a replacement control for
TSpinEdit. It uses a TEdit as a "prototype" visual control and creates a
TUpDownEdit control to provide the visual up-down arrows.
Passing a visual prototype control as a parameter of the constructor can provide
many of the advantages of the IDE (Interactive Development Environment) such a
using the mouse to drop, reposition and resize the control as well as the
ability to use the Object Inspector to set initial value for Properties
and Events. All of this without the need to install a user component.
(One of the limitations of the free Delphi version is that 3rd party components
cannot be installed. To my way of thinking, this is a blessing in
MySpinEdit := TDFFSpinEdit.create(prototype:TEdit; mn, val, mx:integer);
Both of the usual methods of implementing a spin button, TSpinEdit and a TUpDown with an associated Tedit, have deficiencies when minimum or maximum range limits are assigned new values with code. If a change in a range value causes the current value to fall outside of the range, the logical action would be to reset the value to lie on the nearest range limit. For example, if Minvalue and Value are both setting at 10 with Maxvalue at 30 and we change MinValue to 20, I would expect to Value to be reset to 20. TSpinEdit leaves Value at 10. TUpDown with and associated TEdit, changes Position (its name for value) to 20, but does not update the Tedit visual display. TDFFSpinEdit handles this case correctly.
I should mention that the new class has an Assign method which transfers properties and event values from the TEdit prototype. I have only transferred the properties that are essential or that I anticipate needing. If I missed any, le me know.
The demo program contains all 3 versions of spin button controls. I have used conditional version defines to omit TSpinEdit code if compiled under Turbo Delphi ("Version180"), but the compiler will still complain about the definition which occurs in the form definition. Ignoring the error should allow the program to work OK.
Download and Explore Programs
Copyright © 2000-2016, Gary Darby All rights reserved.