Often in a program you cannot simply use edits and buttons as your only forms of input. There are many cases where you need the user to make a choice and specify items using only the mouse. You may also need the user to give a logical
(Boolean, colour etc.) or numerical
(Integer, Real etc.) as opposed to text
(String, Char) input as conveniently as possible. Maybe you just want to add flare to your program. To do all this, you need to use more advanced components, and have a better understanding of the basic ones. The best way to figure these components out is to experiment and practice yourself, but this guide will hopefully give you a good foot to start that experimenting on.
All the pictures show the component on the form during editing, and then the component on an active form using XP Manifest
(a Component that sets your form to an XP / Vista / 7 theme) on Windows 7.
Here are the input components, what they do, their names and how to use them:
 |
Button. btn. |
Button: btn
The button is the most basic form of input. To write code for it simply double click the button on the form. This will create the OnClick Procedure and your code will execute when the button is clicked on.
The button is used as a form of confirmation, the user activates an event with the button when they wish to start a new part of the program.
Other events that can be useful for the Button are the OnMouseDown and OnMouseUp events, this is the clicking and releasing of the left mouse button.
You can change the title of the button with the "Caption" Property, putting the "&" symbol before a letter in the Caption will make that letter with the <Alt> key a shortcut for that button, activating the OnClick event without the user needing their mouse.
=====================================================================================
 |
BitButton. bmb. |
BitMapButton: bmb
The BitButton / BitMapButton is very similar to the plain button. It uses the same events and properties as a simple button, can use a shortcut letter the same way (for example pressing <Alt> + A would trigger the code in the standard OnClick event for this BitButton).
What a BitButton does have that a plain button doesn't, is a glyph. A glyph is the Delphi term for a BitMap image. BitMap images do not resize well, but they are supported by most programs. You can change the image by selecting the "Kind" property
(Warning, choosing the close kind adds code to your button to close the form when the button is clicked) or by loading your own. To do this select the three dots at the end of the "Glyph" property and navigate to any BitMap image you have.
=====================================================================================
 |
SpeedButton. sbn. |
SpeedButton: unsure of the proper name, I personally use:
sbn
The SpeedButton works much the same as the BitButton and Simple Button, however it has two extra properties: The Down and Flat properties. When they are both set to False, it will look like a normal BitButton. When Flat is set to True, it looks like the ones in the pictures on the left, Transparent. The down property makes the button automatically look pressed down, to use this property you need to change the "AllowAllUp" property to True and the "GroupIndex" property to a number bigger than 1. Play around with these settings to get a button that stays pressed in or can be pressed in and out like a checkbox.
=====================================================================================
 |
Edit. edt. |
Edit: edt
The edit is used for the entering of text. It can also be used as an output component with the "ReadOnly" property set to True, but a label is better suited to this. What you see in the Edit is the "Text" property, this is a string. If ever you need to have a number entered, remember to use the StrToInt or StrToFloat code to change the Text to a number that Delphi can work with. The most useful event for the edit is the "OnChange" event, which allows you to execute code every time the text in the edit changes.
You can modify the way an edit displays information using the "PasswordChar" and "CharCase" properties.
=====================================================================================
 |
updown. udn. |
UpDown: unsure of the proper name, I personally use:
udn
The updown is useless as a component on its own, but when attached to another component, such as an edit or label, it becomes useful. The updown requires no code, you simply place it on the form and then choose the object it must affect using the "Associate" property. For example, you can associate it to an edit to make it a type of spin edit. The text is still a string through. You can change the interval that each press gives ( +- whatever the interval is), what the lowest and highest values are and what number the updown starts at. Set any edits to read only if you want to make sure that the user only uses the updown.
=====================================================================================
This will be continued with Advanced Input Components where I will discuss the MaskEdit, ComboBox, RadioGroup and CheckBox. I will also try to do two sections on output components as well as a section on form design components.
The best way to learn about these components is to try and use them yourselves, experiment and remember that most components that use the same logic or idea, use the same code, allowing you to leanr many extra components without touching new code.
Thank-you for reading this, I hope it helps. If you have any advice, need help or anything else I can do via this blog, please say so in the comments.