TRadioButton = class()įunction TRadioButton.GetChecked: Boolean Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Actions, Vcl.ActnList Here is the DPR source: program TRadioButtonGroupingWithTag This (ultimate) answer is based completely on Andreas Rejbrand's idea to use an interposer class only (without new components): Object GroupRadioButton4: TGroupRadioButtonĬaption = 'GroupRadioButton4 (GroupIndex=0)' Object GroupRadioButton3: TGroupRadioButtonĬaption = 'GroupRadioButton3 (GroupIndex=0)' Object GroupRadioButton2: TGroupRadioButtonĬaption = 'GroupRadioButton2 (GroupIndex=1)' Object GroupRadioButton1: TGroupRadioButtonĬaption = 'GroupRadioButton1 (GroupIndex=1)' Vcl.Controls, Vcl.Forms, Vcl.Dialogs, GroupRadioButton, Vcl.StdCtrls Īnd here is the DFM: object Form1: TForm1 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, GroupRadioButton in 'GroupRadioButton.pas' RegisterComponents('PASoft', ) Īnd this is the package PackageGroupRadioButton.dpk: package PackageGroupRadioButton Procedure TGroupRadioButton.SetGroupIndex(const Value: Integer) SendMessage(Handle, BM_SETCHECK, WPARAM(FChecked), 0) If (Sibling Self) and (Sibling is TGroupRadioButton) and (TGroupRadioButton(Sibling).GroupIndex = Self.GroupIndex) then Procedure TGroupRadioButton.SetChecked(Value: Boolean) Winapi.Windows, Vcl.ActnList, Winapi.Messages įunction TGroupRadioButton.GetChecked: Boolean Property GroupIndex: Integer read FGroupIndex write SetGroupIndex Procedure SetGroupIndex(const Value: Integer) System.SysUtils, System.Classes, Vcl.Controls, Vcl.StdCtrls This is the latest version of my new component TGroupRadioButton in GroupRadioButton.pas (Note the new property GroupIndex): unit GroupRadioButton Then in a second step, I am planning to add a property GroupIndex, so that only controls with the same GroupIndex would be unchecked. However, In Objectinspector these 3 controls are still declared as TRadioButton!: Then I redeclared the 3 TRadioButton controls I want to become independent as TMyRadioButton: rbSortNone: TMyRadioButton You can see that I changed the TurnSiblingsOff procedure to consider only TMyRadioButton controls, so not to uncheck the remaining 2 TRadioButton controls. If not (csLoading in ComponentState) and IsCustomStyleActive and Visible then SendMessage(Handle, BM_SETCHECK, WPARAM(Checked), 0) If Assigned(Action) and (Action is TCustomAction) and TCustomAction(Action).AutoCheck then If (Sibling Self) and (Sibling is TMyRadioButton) then Procedure TMyRadioButton.SetChecked(Value: Boolean) Procedure SetChecked(Value: Boolean) override I want to use 3 of them as an INDEPENDENT Group without using a container control such as TPanel for these 3 TRadioButton controls, meaning that when I click on one of these 3 TRadioButton controls, the remaining 2 TRadioButton controls will not be unchecked.įor this purpose, I have overridden the protected SetChecked method in the TRadioButton class: type For TLinkLabel, an HTML tag is declared inside the Caption property either at run time or at design time.In a 32-bit VCL Application in Windows 10 in Delphi 11.1 Alexandria, I have 5 TRadioButton controls directly on a TRelativePanel. With either TSpeedButton or TBitBtn, you can change the color of the Caption property by using the Font property. If you want to change the color of a button caption, you should use an alternate button type such as TSpeedButton or TBitBtn instead of TButton. For some controls, such as TButton, it is not possible to change the color of the Caption.In general, Caption is used for text that appears as a window title or label, while Text is used for text that appears as the content of a control. The property that is used depends on the type of control. Controls that display text use either the Caption property or the Text property to specify the text value.To display an ampersand character in the caption, use two ampersands (&). The user can then select the component by pressing ALT while typing the underlined character. This type of character is called an accelerator character. To underline a character in a Caption that labels a component, include an ampersand (&) before the character. Use Caption to specify the text string that labels the control. Specifies a text string that identifies the control to the user.
0 Comments
Leave a Reply. |