[数量]
NUM=18
JiLu= 2 [记录1]
Point= 点 1
[记录2]
Point= 点 2
[记录3]
Point= 点 3
.....
[记录18]
Point= 点 181.INI文件如上。窗体上有4个竖直排列EDIT.EDIT的TEXT用来显示INI文件中的point值.窗体启动时显示记录1-4的值。
2.3个BUTTON。其中2个是用来控制EDIT上下移动的(DOWN按钮移动是指EDIT的焦点由EDIT1到EDIT2,EDIT2到EDIT3,EDIT3到EDIT4。UP就是相反的。)当EDIT的焦点移动到最后一个时,再次点击,则EDIT1获得焦点,但是EDIT1--4显示的是记录5-8的值。依次类推。
3.还有一个BUTTON,是当EDIT获得焦点时显示它的point值。
希望大家指教,我弄了好长时间了,先谢谢大家。
NUM=18
JiLu= 2 [记录1]
Point= 点 1
[记录2]
Point= 点 2
[记录3]
Point= 点 3
.....
[记录18]
Point= 点 181.INI文件如上。窗体上有4个竖直排列EDIT.EDIT的TEXT用来显示INI文件中的point值.窗体启动时显示记录1-4的值。
2.3个BUTTON。其中2个是用来控制EDIT上下移动的(DOWN按钮移动是指EDIT的焦点由EDIT1到EDIT2,EDIT2到EDIT3,EDIT3到EDIT4。UP就是相反的。)当EDIT的焦点移动到最后一个时,再次点击,则EDIT1获得焦点,但是EDIT1--4显示的是记录5-8的值。依次类推。
3.还有一个BUTTON,是当EDIT获得焦点时显示它的point值。
希望大家指教,我弄了好长时间了,先谢谢大家。
當達到底端(這個值你應該知道的),可翠跳回來。3. 在 Edit.onenter 裏寫個事件。更新這個BUTTON的CAPTION就可翠了
TMyRecord=record
index:integer;
strValue:string;
end;var
Form1: TForm1;
iMRCnt:integer;
MRValue:Array of TMyRecord;
iCurPos,iShowPos:integer;implementation{$R *.dfm}procedure TForm1.DownClick(Sender: TObject);
var
edt:TEdit;
begin
inc(iCurPos);
if iCurPos>=4 then
begin
iCurPos:=0;
if iShowPos<IMRCnt-4 then
inc(iShowPos,4);
ShowIndex(iShowPos);
end; edt:=TEdit(FindComponent('Edit'+IntToStr(iCurPos+1)));
if edt<>nil then
begin
edt.SetFocus;
Button3.Caption:=edt.Text;
end;
end;procedure TForm1.ShowIndex(iPos:integer);
begin
if iPos<iMRCnt then
Edit1.Text:=MRValue[iPos].strValue
else
Edit1.Text:='';
if iPos<iMRCnt-1 then
Edit2.Text:=MRValue[iPos+1].strValue
else
Edit2.Text:='';
if iPos<iMRCnt-2 then
Edit3.Text:=MRValue[iPos+2].strValue
else
Edit3.Text:='';
if iPos<iMRCnt-3 then
Edit4.Text:=MRValue[iPos+3].strValue
else
Edit4.Text:='';
end;procedure TForm1.FormShow(Sender: TObject);
var
iniFile:TIniFile;
i:integer;
begin
iniFile:=TInifile.Create('.\test.ini'); iMRCnt:=iniFile.ReadInteger('ÊýÁ¿','NUM',0);
SetLength(MRValue,iMRCnt);
for i:=0 to iMRCnt-1 do
begin
MRValue[i].index:=i;
MRVAlue[i].strValue:=iniFile.ReadString('¼Ç¼'+IntToStr(i+1),'Point','');
end; iniFile.Free;
iCurPos:=0;
iShowPos:=0;
ShowIndex(iShowPos);
Edit1.SetFocus;
end;procedure TForm1.UpClick(Sender: TObject);
var
edt:TEdit;
begin
inc(iCurPos,-1);
if iCurPos<0 then
begin
iCurPos:=3;
if iShowPos>3 then
inc(iShowPos,-4);
ShowIndex(iShowPos);
end; edt:=TEdit(FindComponent('Edit'+IntToStr(iCurPos+1)));
if edt<>nil then
begin
edt.SetFocus;
Button3.Caption:=edt.Text;
end;
end;end.
index:integer;
strValue:string;
end;var
Form1: TForm1;
iMRCnt:integer;
MRValue:Array of TMyRecord;
iCurPos,iShowPos:integer;implementation{$R *.dfm}procedure TForm1.DownClick(Sender: TObject);
var
edt:TEdit;
begin
inc(iCurPos);
if iCurPos>=4 then
begin
iCurPos:=0;
if iShowPos<IMRCnt-4 then
inc(iShowPos,4);
ShowIndex(iShowPos);
end; edt:=TEdit(FindComponent('Edit'+IntToStr(iCurPos+1)));
if edt<>nil then
begin
edt.SetFocus;
Button3.Caption:=edt.Text;
end;
end;procedure TForm1.ShowIndex(iPos:integer);
begin
if iPos<iMRCnt then
Edit1.Text:=MRValue[iPos].strValue
else
Edit1.Text:='';
if iPos<iMRCnt-1 then
Edit2.Text:=MRValue[iPos+1].strValue
else
Edit2.Text:='';
if iPos<iMRCnt-2 then
Edit3.Text:=MRValue[iPos+2].strValue
else
Edit3.Text:='';
if iPos<iMRCnt-3 then
Edit4.Text:=MRValue[iPos+3].strValue
else
Edit4.Text:='';
end;procedure TForm1.FormShow(Sender: TObject);
var
iniFile:TIniFile;
i:integer;
begin
iniFile:=TInifile.Create('.\test.ini'); iMRCnt:=iniFile.ReadInteger('数量','NUM',0);
SetLength(MRValue,iMRCnt);
for i:=0 to iMRCnt-1 do
begin
MRValue[i].index:=i;
MRVAlue[i].strValue:=iniFile.ReadString('记录'+IntToStr(i+1),'Point','');
end; iniFile.Free;
iCurPos:=0;
iShowPos:=0;
ShowIndex(iShowPos);
Edit1.SetFocus;
end;procedure TForm1.UpClick(Sender: TObject);
var
edt:TEdit;
begin
inc(iCurPos,-1);
if iCurPos<0 then
begin
iCurPos:=3;
if iShowPos>3 then
inc(iShowPos,-4);
ShowIndex(iShowPos);
end; edt:=TEdit(FindComponent('Edit'+IntToStr(iCurPos+1)));
if edt<>nil then
begin
edt.SetFocus;
Button3.Caption:=edt.Text;
end;
end;end.