一段程序原代码(请帮忙修改) (1分)

  • 主题发起人 主题发起人 newboy_kdg
  • 开始时间 开始时间
N

newboy_kdg

Unregistered / Unconfirmed
GUEST, unregistred user!
这段程序是运行时动态创建56个按键
但是在运行的时候出错无法生成
(新手上路,请多指教)
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
GroupBoxShortCutCall: TGroupBox;
private
{ Private declarations }
ShortcutCallA : Array [1..56] of TGroupBox;
btLeft, btTop, btWidth, btHeight : integer;
procedure CreateShortcutCallButtons;
public
{ Public declarations }
end;

var
Form1: TForm1;


implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.CreateShortcutCallButtons;
var i,j:integer;
begin
btLeft:=10;
btTop:=20;
btWidth:=53;
btHeight:=25;
for i:=1 to 8 do
for j:=1 to 7 do
begin
ShortcutCallA[(i-1)*7+j].ShotcutCallButton:=SpeedButton.Create(nil);
with ShortcutCallA[(i-1)*7+j].ShortcutCallButton do
begin
Left:=btLeft+(j-1)*btWidth;
Top:= btTop +(i-1)*btHeight;
Width:=btWidth;
Height:=btHeight;
Parent:=GroupBoxShortcutCall;
Visible:=True;

end;
end;
GroupBoxShortcutCall.Update;

end;

end.
 
是少定义了什么吧
 
所定义的数组类型为:TGroupBox,但在程序中却用的是SpeedButton!!!
 
改过来之后,运行还有5条错误!请指教
[Error] Unit1.pas(14): Undeclared identifier: 'TShortCutCall'
[Error] Unit1.pas(44): Missing operator or semicolon
[Error] Unit1.pas(45): 'DO' expected but identifier 'ShortcutCallButton' found
[Hint] Unit1.pas(17): Private symbol 'CreateShortcutCallButtons' declared but never used
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
 
帮一下,,谢谢
 
请仔细比较与你的代码有什么不同

unit Unit1;

interface

uses
Windows, Messages, SysUtils,Classes, Controls, StdCtrls, Graphics, Forms,
Dialogs,
buttons;

type
TForm1 = class(TForm)
GroupBoxShortCutCall: TGroupBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
ShortcutCallA : Array [1..56] of TSpeedButton;
btLeft, btTop, btWidth, btHeight : integer;
procedure CreateShortcutCallButtons;
public
{ Public declarations }
end;

var
Form1: TForm1;


implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.CreateShortcutCallButtons;
var i,j:integer;
begin
btLeft:=10;
btTop:=20;
btWidth:=53;
btHeight:=25;
for i:=1 to 8 do
begin
for j:=1 to 7 do
begin
ShortcutCallA[(i-1)*7+j]:= TSpeedButton.Create(nil);
with ShortcutCallA[(i-1)*7+j] do
begin
Left:=btLeft+(j-1)*btWidth;
Top:= btTop +(i-1)*btHeight;
Width:=btWidth;
Height:=btHeight;
Parent:=GroupBoxShortcutCall;
Visible:=True;
end;
end;
end;
GroupBoxShortcutCall.Update;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
CreateShortcutCallButtons;
end;

end.
 
首先感谢这位大霞相助,,不过这段程序你真的运行了吗?
我运行的结果并没有产生56个按键啊,,
还有,,这个按键是需要在运行界面的同时产生的,,
应该不用button1吧?
谢谢!
 
谢谢,我又试过了,,运行ok!
原来可以不用点击button生成按键,,
可以在formcreat中或formshoe中自动生成,,
谢谢,,,一分送上,,
 
接受答案了.
 
后退
顶部