delphi-7 - mysq[i].caption 到 delphi 7 上的 editbox.text
问题描述
当我只想要字母时,我会一直使用这个程序获得完整的字母表。我如何获得具体的信件?
var
Form1: TForm1;
mysq : array[1..26] of TPanel;
implementation
…
procedure TForm1.mySqMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i, a: integer;
begin
a := StrToInt(lab_leftn.Caption);
lab_leftn.Caption := IntToStr(a - 1);
if lab_leftn.Caption = IntToStr(0) then
begin
ShowMessage('You have lost');
lab_leftn.Caption := IntToStr(0);
end;
for i := 1 to 26 do
ed_guessed.Text := ed_guessed.Text + mysq[i].Caption;
end;
解决方案
假设 mySqMouseDown 已分配给所有 TPanel OnMouseDown 事件,那么正确的代码是这个:
procedure TForm1.mySqMouseDown(
Sender : TObject;
Button : TMouseButton;
Shift : TShiftState;
X, Y : Integer);
var
i, a: integer;
begin
a := StrToInt(lab_leftn.Caption);
lab_leftn.Caption := IntToStr(a - 1);
if lab_leftn.Caption = IntToStr(0) then begin
ShowMessage('You have lost');
lab_leftn.Caption := IntToStr(0);
end;
ed_guessed.Text := (Sender as TPanel).Caption;
end;
推荐阅读
- snort - 减少/限制 Snort 规则触发器 (Syn Flood) 发生的警报数量
- wagtail - 如何将页面 ID 用于 Wagtail 的自定义 URL
- excel - 将范围从一个工作簿复制到另一个工作簿
- c# - WMI 访问被拒绝
- google-cloud-platform - 执行许多工作流任务的经济可能性
- python - 使用对象列表创建不同的进程
- javascript - 从反应组件调用 Javascript 函数
- angular - 角度材料表 - 排序方向未在屏幕阅读器中读取
- php - 从服务器发送邮件,同时从 android 中的凌空接收错误
- spring-boot - 如何评估百里香模板中嵌套对象的字段?