# Form Utilities Forms and components extensions. This files contains custom components and methods to be used in forms. - - - ## TControl.IsInitiated ```pascal function TControl.IsInitiated(): Boolean; ``` Checks if the control has already been initiated. - - - ## TControl.Set ```pascal procedure TControl.SetTooltip(value: String); procedure TControl.SetFontColor(value: Int32); procedure TControl.SetChildsFontColor(value: Int32); ``` TControl.Set methods. Their names are self explanatory. For some reason TControl.SetHint cannot be overriden, so a custom method for this was made. - - - ## TControl.Get ```pascal function TControl.GetRight(): Int32; function TControl.GetBottom(): Int32; ``` TControl.Get methods. Their names are self explanatory. - - - ## Component.NumberField ```pascal procedure TComponent.NumberField(sender: TObject; var key: char); ``` Callback method to limit user input to numbers only and backspace. This numbers can be Ints or Doubles. - - - ## Component.TimeField ```pascal procedure TComponent.TimeField(sender: TObject; var key: char); ``` Callback method to limit user input to numbers only, backspace and a few characters used in time. - - - ## Component.NumberArrayField ```pascal procedure TComponent.NumberArrayField(sender: TObject; var key: char); ``` Callback method to limit user input to a TIntegerArray. - - - ## Control.OpenLink ```pascal procedure TControl.OpenLink(sender: TObject); ``` Open the link in the control caption. - - - ## CustomEdit.IsEmpty ```pascal function TCustomEdit.IsEmpty(): Boolean; ``` Returns true or false if the TCustomEdit (TEdit and TMemo) are empty. - - - ## CustomEdit.GetIntegerArray ```pascal function TCustomEdit.GetIntegerArray(): TIntegerArray; ``` Returns the TIntegerArray in the TCustomEdit (TEdit and TMemo). It's probably a good idea to limit the TCustomEdit input with **TComponent.IntArrayField()**. - - - ## TControl.Create ```pascal procedure TPanel.Create(owner: TControl); procedure TPageControl.Create(owner: TControl); procedure TTabSheet.Create(owner: TControl); procedure TImage.Create(owner: TControl); procedure TLabel.Create(owner: TControl); procedure TEdit.Create(owner: TControl); procedure TButton.Create(owner: TControl); procedure TCheckBox.Create(owner: TControl); procedure TRadioButton.Create(owner: TControl); procedure TComboBox.Create(owner: TControl); procedure TListBox.Create(owner: TControl); procedure TMemo.Create(owner: TControl); procedure TTrackBar.Create(owner: TControl); ``` `TControl.Init()` and `TControl.SetParent()` in a single method. Since this is something that has to be done almost always this wrapper was made. - - - ## TImage.LoadFromFile ```pascal procedure TImage.LoadFromFile(path: String); ``` Load a image file to a TImage directly. - - - ## TControl.LoadFromFile ```pascal procedure TControl.LoadFromFile(path: String); ``` Load a image file and set it as the background for a TControl. This can be used to set images for TPanels, TPageControls, TTabSheet, TButtons, etc. - - - ## TControl.SwapImage ```pascal procedure TControl.SwapImage(path: String); ``` Load a new image file and set it as the new background for a TControl. This can be used to swap images for TPanels, TPageControls, TTabSheet, TButtons, etc. If the TControl doesn't have an image yet, this will also set it up. - - - ## TControl.GetTrueWidth ```pascal function TControl.GetTrueWidth(): Int32; ``` Get the true width of the TControl caption. - - - ## TControl.GetTrueHeight ```pascal function TControl.GetTrueHeight(): Int32; ``` Get the true height of the TControl caption. - - - ## CheckBox.SetChecked ```pascal procedure TCheckBox.SetChecked(value: Boolean); ``` Sets the checkbox checked or unchecked with a boolean. - - - ## CheckBox.IsChecked ```pascal function TCheckBox.IsChecked(): Boolean; ``` Gets the checkbox state, checked or unchecked with a boolean. - - - ## CheckBox.Toggle ```pascal procedure TCheckBox.Toggle(); ``` Inverts the checkbox. - - - ## LabeledControl ```pascal type TLabeledControl = record Panel: TPanel; Caption: TLabel; end; ``` TLabeledControl is the base type for custom TLabeledControls. It's not really meant to be used directly. If for some reason you need to see the control bounds, it's recommended to set the panel bevel width to 1. Changing TLabeledControl subcomponents align value can mess the position of everything. - - - ## TLabeledPanel ```pascal TLabeledPanel = type TLabeledControl; ``` Same exact thing as a TLabeledControl but with the purpose of being a panel for other components. - - - ## LabeledEdit ```pascal type TLabeledEdit = record(TLabeledControl) Edit: TEdit; end; ``` TLabeledEdit is, as the name implies a TEdit with a TLabel on top. Both components are contained in the TPanel inherited from TLabeledControl. - - - ## LabeledCheckBox ```pascal type TLabeledCheckBox = record(TLabeledControl) CheckBox: TEdit; end; ``` TLabeledCheckBox is, as the name implies a TCheckBox with a TLabel to it's right. Both components are contained in the TPanel inherited from TLabeledControl. ```{note} The standard TCheckBox already has a label by it but it's hard to customize it. ``` - - - ## LabeledComboBox ```pascal type TLabeledComboBox = record(TLabeledControl) ComboBox: TComboBox; end; ``` TLabeledComboBox is, as the name implies a TComboBox with a TLabel on top. Both components are contained in the TPanel inherited from TLabeledControl. - - - ## LabeledListBox ```pascal type TLabeledListBox = record(TLabeledControl) ListBox: TListBox; end; ``` TLabeledListBox is, as the name implies a TListBox with a TLabel on top. Both components are contained in the TPanel inherited from TLabeledControl. - - - ## LabeledMemo ```pascal type TLabeledMemo = record(TLabeledControl) Memo: TMemo; end; ``` TLabeledMemo is, as the name implies a TMemo with a TLabel on top. Both components are contained in the TPanel inherited from TLabeledControl. - - - ## LabeledTrackBar ```pascal type TLabeledTrackBar = record(TLabeledControl) TrackBar: TTrackBar; end; ``` TLabeledTrackBar is, as the name implies a TTrackBar with a TLabel on top. Both components are contained in the TPanel inherited from TLabeledControl. - - - ## CheckCheckGroup ```pascal type TCheckCheckGroup = record(TLabeledCheckBox) CaptionPanel, GroupPanel: TPanel; Group: array of TLabeledCheckBox; end; ``` TCheckCheckGroup is, a custom component. The best way to describe it is a TLabeledCheckBox group that the caption itself is a checkbox to enable/disable the whole group. - - - ## LabeledControl.IsInitiated ```pascal function TLabeledControl.IsInitiated(): Boolean; ``` Checks if the custom labeled control has already been initiated. - - - ## TLabeledControl.Create ```pascal procedure TLabeledControl.Create(owner: TControl); procedure TLabeledPanel.Create(owner: TControl); override; procedure TLabeledEdit.Create(owner: TControl); override; procedure TLabeledCheckBox.Create(owner: TControl); override; procedure TLabeledComboBox.Create(owner: TControl); override; procedure TLabeledListBox.Create(owner: TControl); override; procedure TLabeledMemo.Create(owner: TControl); override; procedure TLabeledTrackBar.Create(owner: TControl); override; ``` Custom components `TLabeledControl.Init()` and `TLabeledControl.SetParent()` in a single method. Since this is used very often a wrapper was made. - - - ## LabeledControl.SetCaption ```pascal procedure TLabeledControl.SetCaption(value: String); ``` Set the labeled control caption. - - - ## LabeledControl.SetHint ```pascal procedure TLabeledControl.SetHint(value: String); ``` Set the labeled control hint (tooltip). - - - ## LabeledControl.ShowHint ```pascal procedure TLabeledControl.ShowHint(); ``` Sets show hint (tooltip) to true. - - - ## LabeledControl.SetShowHint ```pascal procedure TLabeledControl.SetShowHint(value: Boolean); ``` Sets show hint (tooltip) to true or false. - - - ## LabeledControl.SetTooltip ```pascal procedure TLabeledControl.SetTooltip(value: String); ``` Same as the previous one but makes sure that .ShowHint() is enabled if **value** was not empty. For more info read about TControl.SetTooltip(). - - - ## LabeledControl.SetName ```pascal procedure TLabeledEdit.SetName(value: String); procedure TLabeledCheckBox.SetName(value: String); procedure TLabeledComboBox.SetName(value: String) procedure TLabeledListBox.SetName(value: String); procedure TLabeledMemo.SetName(value: String); procedure TLabeledTrackBar.SetName(value: String); ``` Sets names to the subcomponents of the TLabeledControl. Caption is named with **value** + '_caption' while the other component is appended with it's name. - - - ## LabeledControl.Set ```pascal procedure TLabeledControl.SetLeft(value: Int32); procedure TLabeledControl.SetTop(value: Int32); procedure TLabeledControl.SetWidth(value: Int32); procedure TLabeledControl.SetHeight(value: Int32); procedure TLabeledControl.SetAlign(value: TAlign); procedure TLabeledControl.SetColor(value: Int32); procedure TLabeledControl.SetFontColor(color: TColor); procedure TLabeledControl.SetFontSize(size: Int32); procedure TLabeledControl.SetVisible(value: Boolean); ``` TLabeledControl Set methods. The methods are self explanatory. The only thing that should be kept in mind is that they only interactwith the TLabeledControl.Panel. - - - ## LabeledControl.BringToFront ```pascal procedure TLabeledControl.BringToFront(); ``` Brings the control to front. - - - ## LabeledControl.Get ```pascal function TLabeledControl.GetLeft(): Int32; function TLabeledControl.GetTop(): Int32; function TLabeledControl.GetRight(): Int32; function TLabeledControl.GetBottom(): Int32; function TLabeledControl.GetHeight(): Int32; function TLabeledControl.GetVisible(): Boolean; ``` TLabeledControl Get methods. The methods are self explanatory. - - - ## LabeledControl.SetText ```pascal procedure TLabeledEdit.SetText(value: String); procedure TLabeledComboBox.SetText(value: String); procedure TLabeledMemo.SetText(value: String); ``` Sets the visible text in the TLabeledControl to **value**. - - - ## LabeledControl.GetText ```pascal function TLabeledEdit.GetText(): String; function TLabeledComboBox.GetText(): String; function TLabeledListBox.GetText(): String; function TLabeledMemo.GetText(): String; ``` Gets the visible or selected text in the TLabeledControl. Example: ```pascal WriteLn myEdit.GetText(); ``` - - - ## LabeledControl.GetName ```pascal function TLabeledControl.GetName(): String; ``` Gets the TLabeledControl name. - - - ## LabeledControl.Clear ```pascal procedure TLabeledEdit.Clear(); procedure TLabeledComboBox.Clear(); procedure TLabeledListBox.Clear(); procedure TLabeledMemo.Clear(); ``` Clears the TLabeledControl. - - - ## LabeledCheckBox.SetChecked ```pascal procedure TLabeledCheckBox.SetChecked(value: Boolean); ``` Sets the checkbox or not depending on **value**. - - - ## LabeledCheckBox.IsChecked ```pascal function TLabeledCheckBox.IsChecked(): Boolean; ``` Gets the checkbox state true or false. - - - ## LabeledCheckBox.GetState ```pascal function TLabeledCheckBox.GetState(): TCheckBoxState; ``` Gets the checkbox state. - - - ## LabeledControl.SetEnabled ```pascal procedure TLabeledEdit.SetEnabled(value: Boolean); procedure TLabeledCheckBox.SetChecked(value: Boolean); procedure TLabeledComboBox.SetEnabled(value: Boolean); procedure TLabeledListBox.SetEnabled(value: Boolean); procedure TLabeledMemo.SetEnabled(value: Boolean); ``` Sets the checkbox or not depending on **value**. - - - ## LabeledControl.SetPasswordChar ```pascal procedure TLabeledEdit.SetPasswordChar(value: Char = '*'); procedure TLabeledMemo.SetPasswordChar(value: Char = '*'); ``` Sets the TLabeledControl to hide the displayed text with **value** characters. Mostly used to hide passwords. - - - ## LabeledControl.SetMaxLength ```pascal procedure TLabeledEdit.SetMaxLength(value: Int32); procedure TLabeledMemo.SetMaxLength(value: Int32); ``` Sets the maximum length of characters accepted by the TLabeledControl. - - - ## LabeledControl.GetMaxLength ```pascal function TLabeledEdit.GetMaxLength(): Int32; function TLabeledMemo.GetMaxLength(): Int32; ``` Returns the maximum length of characters accepted by the TLabeledControl. - - - ## LabeledControl.SetStyle ```pascal procedure TLabeledComboBox.SetStyle(value: TComboBoxStyle); procedure TLabeledListBox.SetStyle(value: TListBoxStyle); ``` Sets the TLabeledControl style. - - - ## LabeledControl.AddItem ```pascal procedure TLabeledCombobox.AddItem(value: String); procedure TLabeledListBox.AddItem(value: String); ``` Adds an item to the TLabeledControl. - - - ## LabeledControl.AddItemArray ```pascal procedure TLabeledCombobox.AddItemArray(valueArray: TStringArray); procedure TLabeledListBox.AddItemArray(valueArray: TStringArray); procedure TCheckCheckGroup.AddItemArray(valueArray: TStringArray); ``` Adds an array of items to the TLabeledControl. - - - ## LabeledControl.SetItemIndex ```pascal procedure TLabeledCombobox.SetItemIndex(value: Int32); procedure TLabeledListBox.SetItemIndex(value: Int32); ``` Sets the selected index for the TLabeledControl. - - - ## LabeledControl.GetItemIndex ```pascal function TLabeledCombobox.GetItemIndex(): Int32; function TLabeledListBox.GetItemIndex(): Int32; ``` Gets the selected index of the TLabeledControl.