
20.04.2011, 13:01
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
Код:
unit Unit1;
interface
uses
Buttons,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ButtonMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
stringlist: TStringList;
i: Integer;
btn: TBitBtn;
begin
stringlist:=TStringList.Create;
try
stringlist.LoadFromFile('c:\Downloads\avatar.js');
for i:=0 to stringlist.Count-1 do
begin
btn:=TBitBtn.Create(Self);
btn.Parent:=StringGrid1;
btn.Caption:=Format('Button %d', [i]);
btn.BoundsRect:=StringGrid1.CellRect(1, i+1);
btn.ShowHint:=False;
btn.Hint:=stringlist[i];
btn.OnMouseUp:=ButtonMouseUp;
end;
finally
stringlist.Free;
end;
end;
procedure TForm1.ButtonMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ShowMessage(TBitBtn(Sender).Hint);
end;
end.
__________________
Пишу программы за еду.
__________________
|