小编use*_*565的帖子

Delphi7,创建组合框项目

我想使用combobox为用户提供各种选项.所以有2个组合框.第一个有大约5个选项,第二个项目将根据用户在第一个组合框中选择的内容创建.

到目前为止,我已经尝试过这个:Combobox2.Items.Strings[1]:='xxxx'这出现了我的错误:

List out of Bound.
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

delphi combobox

5
推荐指数
1
解决办法
2万
查看次数

Delphi7,Showmessage命令在应用程序表单出现之前执行

我想知道为什么命令"showmessage"在申请表出现之前执行,我的意思是,每当我运行程序时,首先出现消息,然后是申请表:

procedure TForm1.FormCreate(Sender: TObject);
begin
button1.hide;
button2.hide;
image3.picture.loadfromfile('c:\EAS\std.bmp');
showmessage ('Hi');
end;

end.
Run Code Online (Sandbox Code Playgroud)

delphi做的第一件事就是显示消息"Hi".然后它完成剩下的工作(表单出现,隐藏按钮,加载图像等).尽管showmessage是最后一个,但它首先被执行.如何在表单出现后显示消息,按钮是否隐藏图像是否已加载?

谢谢

delphi message action

3
推荐指数
1
解决办法
1867
查看次数

如何使编辑控件不接受0作为第一个数字?

好吧,我有一个只采用数字的编辑(没有字母,没有符号,只有数字).问题是我不希望用户将0作为第一个数字,例如(0239847).

我正在考虑制作一个变量"x" - >字节,它将计算编辑的长度并删除第一个数字,如果它是0:

var l:length; number:string100;
begin
l:length(edit1.text);
Run Code Online (Sandbox Code Playgroud)

现在,如果第一个数字是0(0239847),则删除它,但如果没有其他数字(仅为0),则保持原样.

哦,我终于找到了最简单的方法:

procedure TForm1.Edit1Change(Sender: TObject);
var digit1:string;
begin
digit1:=edit1.Text;
if (digit1='00') or (digit1='01') or (digit1='02') or (digit1='03') or (digit1='04') or
(digit1='05') or (digit1='06') or (digit1='07') or (digit1='08') or (digit1='09') then
edit1.Text:=clear;    //or edit1.text:=0;  it's the same

end;

end.
Run Code Online (Sandbox Code Playgroud)

仍然可以复制和粘贴数字,但我不介意

这是一个非常愚蠢的问题,因为答案很简单明了,但是如果你太累了,很难找到它,我很抱歉让你为此忙,Andreas,感谢你的帮助和提示.

delphi delphi-7

3
推荐指数
1
解决办法
1251
查看次数

Delphi7,Randomize,从1到6中选择随机数,但不是0

我想制作2个骰子,但我不希望它选择0,这是我的代码:

procedure TForm1.Button1Click(Sender: TObject);
var x1,x2:integer; text1,text2:string;
begin
randomize;
x1:=random(7);
x2:=random(7);

text1:=inttostr(x1);
text2:=inttostr(x2);

label1.Caption:=text1;
label2.Caption:=text2;

end;
end.
Run Code Online (Sandbox Code Playgroud)

我该怎么办才能让它从1到6中选择,不包括0?谢谢

delphi random numbers

3
推荐指数
1
解决办法
4313
查看次数

Delphi7,由于按钮,我无法使用UP,DOWN,LEFT,RIGHT键移动图像

标题没有说很多东西,所以让我解释一下:

我已经制作了一个申请表,其中我放了1张图片和4个按钮.每当我按下按键:向上,向下,向左,向右移动图像时,它会选择按钮,保证移动图像.例如,如果我按下向下键,它将选择我按钮2,如果我按下它,它将选择我按钮1 ....

我是sry,我无法真正描述它的样子,在你的表单上尝试它,你会看到我的意思,代码是这样的:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
    VK_UP:
      image1.Top := image1.Top - 10;
    VK_DOWN:
      image1.Top := image1.Top + 10;
    VK_LEFT:
      image1.Left := image1.Left - 10;
    VK_RIGHT:
      image1.Left := image1.Left + 10;
   end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi image key move button

1
推荐指数
1
解决办法
1480
查看次数

Delphi7,按下Up键时进行形状​​跳转

当玩家按下UP键时,我想做一个形状跳跃,所以我能想到的最好的是这个,但我使用的方法很糟糕且有问题:

(形状坐标:shape1.top:=432;)

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
case key of
vk_up: shape1.top:=shape1.top-40   //so that it jumps to 392
end; 
end;
Run Code Online (Sandbox Code Playgroud)

现在这个计时器:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.interval:=300
if shape1.Top<400 then      //if shape1.top=392 < 400
begin
shape1.Top:=432;            //move back to 432
end;

end;
Run Code Online (Sandbox Code Playgroud)

问题是玩家可以不断按下UP键,这是我不想要的.我知道这种方法很糟糕,所以我希望你有比这更好的东西,如果你能和我分享,我将不胜感激.

delphi key shape

0
推荐指数
1
解决办法
2094
查看次数

Delphi7,使用Tmediaplayer重复声音

我正在使用delphi7.我想在我的程序中放一首歌,但我不希望它永远不会结束.我尝试使用计时器,但它没有播放音乐:

procedure TForm1.FormCreate(Sender: TObject);
begin
timer1.enabled:=true;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var playsound,destination:string;
begin

destination:=paramstr(0); 
playsound:=extractfilepath(destination)+'Soundtrack\play.wma';

mediaplayer1.FileName:=playsound;                
mediaplayer1.Open;
mediaplayer1.Play;                        //USING TMEDIAPLAYER

end;
Run Code Online (Sandbox Code Playgroud)

此代码中没有语法错误,但是歌曲没有运行,也许计时器不适用于该作业.我该怎么办?谢谢

delphi audio repeat media-player

-2
推荐指数
1
解决办法
2448
查看次数

Delphi7,保存用户的更改或其他用户的信息/注释

在我的程序中,用户完成一个表单然后按下Submit.然后,创建文本文件或随机扩展文件,其中写入所有用户的信息.因此,每当用户运行应用程序表单时,它将检查是否存在具有所有信息的文件,然后复制信息并将其粘贴到表单中.但是,它由于某种原因不起作用(没有语法错误):

procedure TForm1.FormCreate(Sender: TObject);
var
  filedest: string;
  f: TextFile;
  info: array[1..12] of string;
begin
  filedest := ExtractFilePath(ParamStr(0)) + 'User\Identity\IdentityofMyself.txt';

  if FileExists(filedest) then
  begin
    AssignFile(f,filedest);
    Reset(f);

    ReadLn(info[1], info[2], info[3], info[4], info[5], info[6], info[7],
      info[8], info[9], info[10], info[11], info[12]);     

    Edit1.Text := info[1];
    Edit2.Text := info[2];
    ComboBox1.Text := info[3];            
    ComboBox5.Text := info[4];
    ComboBox8.Text := info[4];
    ComboBox6.Text := info[5];
    ComboBox7.Text := info[6];
    Edit3.Text := info[7];
    Edit4.Text := info[8];
    Edit5.Text := info[11];
    Edit6.Text := info[12];
    ComboBox9.Text := info[9];
    ComboBox10.Text := info[10];     

    CloseFile(f);                                           
  end …
Run Code Online (Sandbox Code Playgroud)

delphi exists save

-2
推荐指数
1
解决办法
129
查看次数

标签 统计

delphi ×8

key ×2

action ×1

audio ×1

button ×1

combobox ×1

delphi-7 ×1

exists ×1

image ×1

media-player ×1

message ×1

move ×1

numbers ×1

random ×1

repeat ×1

save ×1

shape ×1