When creating a TCheckBox
on a custom form, there appears there is a limit of only 15 characters that can be displayed in the Caption
property.
[Code]
var
OptionsWindowForm: TForm;
{ Show the Options window }
procedure ShowOptionsWindow;
var
SlowNetworkLabel: TNewStaticText;
SlowNetworkCheckBox: TNewCheckBox;
begin
OptionsWindowForm := TForm.Create(nil);
with OptionsWindowForm do
begin
Parent := WizardForm;
BorderStyle := bsDialog;
Position := poScreenCenter;
ClientWidth := ScaleX(400);
ClientHeight := ScaleY(140);
Caption := '{#AppName} Options';
end;
{ Define the Slow Network checkbox }
SlowNetworkCheckBox := TNewCheckBox.Create(WizardForm);
with SlowNetworkCheckBox do
begin
Parent := OptionsWindowForm;
Left := OptionsLabel.Left + ScaleX(4);
Top := OptionsLabel.Top + ScaleY(20);
Caption := 'Slow Network Connection: Run Remotely';
Checked := False;
OnClick := @SlowNetworkCheckBoxClick;
end;
OptionsWindowForm.ShowModal;
end;
So, in this example all that is displayed is "Slow Network Co", after which the text is truncated. There is an obvious workaround to create a label and overlay it next to the checkbox.
{ Define the Slow Network label }
SlowNetworkLabel := TNewStaticText.Create(WizardForm);
with SlowNetworkLabel do
begin
Parent := OptionsWindowForm;
Left := SlowNetworkCheckBox.Left + ScaleX(16);
Top := SlowNetworkCheckBox.Top + ScaleY(2);
Caption := 'Slow Network Connection: Run Remotely';
end;
However, the downside to doing this means that you can only click in the checkbox to select or deselect it. Without the overlayed label, the caption text of the checkbox is also clickable. Therefore, this is not an ideal solution as the user has to be far more accurate with their mouse click to select the checkbox. Therefore, is there a way to increase the caption length? 15 characters seems like a very significant limit.
Combo boxes do not auto-size with its caption (contrary to TLabel
).
Just make the combo box as wide as possible.
with SlowNetworkCheckBox do
begin
Parent := OptionsWindowForm;
Width := Parent.ClientWidth - Left - ScaleX(8);
{ ... }
end;