Combobox 选择后设置组合框标题
我在FreePascal(Lazarus IDE)中有一个小工具wirtten,还有一个组合框,可以根据Ini条目更改工具的大小。大小调整正常,但在用户选择组合框大小写后,重置标题时遇到问题。我试图让它,组合框的标题总是设置,即使用户选择了一个案例。当前,在选择组合框大小写后,框变为空白(没有标题,但您仍然可以选择大小写)。我将ItemIndex设置为-1,但没有成功。也许我在监督什么。这是我的代码:Combobox 选择后设置组合框标题,combobox,freepascal,lazarus,Combobox,Freepascal,Lazarus,我在FreePascal(Lazarus IDE)中有一个小工具wirtten,还有一个组合框,可以根据Ini条目更改工具的大小。大小调整正常,但在用户选择组合框大小写后,重置标题时遇到问题。我试图让它,组合框的标题总是设置,即使用户选择了一个案例。当前,在选择组合框大小写后,框变为空白(没有标题,但您仍然可以选择大小写)。我将ItemIndex设置为-1,但没有成功。也许我在监督什么。这是我的代码: unit Unit1; {$mode objfpc}{$H+} interface us
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Buttons, FileUtil, IniFiles;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
procedure Button1Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure confCheck();
private
public
end;
var
Init, Language, Version, Enhancements, Mods, Size, Custom: String;
BackgroundList: TStrings;
MusicList: TStrings;
LogoList: TStrings;
Form1: TForm1;
Faktor: extended;
Config: TIniFile;
implementation
{$R *.lfm}
{ TForm1 }
const
IniFile = 'conf.ini';
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case ComboBox1.ItemIndex of
0: begin
Config := TIniFile.Create(IniFile);
try
Config.WriteString('Size', 'Size', 'XL');
finally
Config.free;
end;
end;
1: begin
Config := TIniFile.Create(IniFile);
try
Config.WriteString('Size', 'Size', 'L');
finally
Config.free;
end;
end;
2: begin
Config := TIniFile.Create(IniFile);
try
Config.WriteString('Size', 'Size', 'M');
finally
Config.free;
end;
end;
3: begin
Config := TIniFile.Create(IniFile);
try
Config.WriteString('Size', 'Size', 'S');
finally
Config.free;
end;
end;
end;
confCheck;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Close();
end;
procedure TForm1.confCheck();
begin
Config := TIniFile.Create(IniFile);
try
Language :=Config.ReadString('Language', 'Language', '');
Size :=Config.ReadString('Size', 'Size', '');
//Setting of Tool-Size
if Size='XL' then
begin
Faktor:=1;
end
else if Size='L' then
Faktor:=1.6
else if Size='M' then
Faktor:=2.4
else if Size='S' then
Faktor:=3.6;
//Dynamic Tool-Size
Width:=round(Screen.Width/Faktor);
Height:=round(Screen.Height/Faktor);
//Positioning of Tool-Size
Form1.position := poScreenCenter;
Form1.BorderStyle := bsNone;
//Setting of Captions
if Language='German' then
begin
ComboBox1.Text:='Größe wählen';
ComboBox1.Items.Clear;
ComboBox1.Items.Add('Vollbildschirm');
ComboBox1.Items.Add('Größe L');
ComboBox1.Items.Add('Größe M');
ComboBox1.Items.Add('Größe S');
end
else if Language='English' then
begin
ComboBox1.Text:='Choose Size';
ComboBox1.Items.Clear;
ComboBox1.Items.Add('Fullscreen');
ComboBox1.Items.Add('Size L');
ComboBox1.Items.Add('Size M');
ComboBox1.Items.Add('Size S');
end;
ComboBox1.ItemIndex:=-1;
finally
Config.free;
end;
end;
end.