Spinedit Replacement (TDFFSpinEdit)

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

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 disguise.)    

This technique does require that we create the control in code, usually in a FormCreate event exit.  To create the control we'll  pass the prototype and the initial Minvalue, Value, and Maxvalue property values.  For example:

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

Click to download source code for DFFSpinEdit and the demo program. 

Future Explorations

???


 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.