Вниз
Скачать: CL | DM;

Вопрос по созданию компонент.   Найти похожие ветки 

 
siriusP   (2004-04-20 17:18) [0]

Прошу прощения за чайниковский вопрос.

Есть компонент от TPanel, в нем свойство - список кнопок.
Как написать событие, которое бы меняло Glyph при нажатии на соот-ую кнопку (или что-то еще).
И еще, в дизайнере при выборе GlyphDown или GlyphUndown картинки на кнопках обновляются, а
после компиляции кнопки опять пустые. Почему?

 TMySpeedButton = class(TSpeedButton)
 protected
   FCol: integer;
   FRow: integer;
 public
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
   property Col: integer read FCol write FCol;
   property Row: integer read FRow write FRow;
 end;

 TPanelEx = class(TPanel)
 protected
   FMySpeedButtonList: TList;
   FGlyphDown: TBitmap;
   FGlyphUndown: TBitmap;

   procedure SetGlyphDown(aGlyphDown: TBitmap);virtual;
   procedure SetGlyphUndown(aGlyphUndown: TBitmap);virtual;
   function GetGlyphDown: TBitmap;virtual;
   function GetGlyphUndown: TBitmap;virtual;
 public
   constructor Create(AOwner: TComponent); override;
   destructor Destroy; override;
 published
   property GlyphDown: TBitmap read GetGlyphDown write SetGlyphDown;
   property GlyphUndown: TBitmap read GetGlyphUndown write SetGlyphUndown;
 end;

constructor TPanelEx.Create(AOwner: TComponent);
 var tmpI, tmpJ, tmpIndx: integer;
     tmpSpeedButton: TMySpeedButton;
begin
 inherited Create(AOwner);
 FGlyphDown:= TBitmap.Create;
 FGlyphUndown:= TBitmap.Create;

 Height:= 350;
 Width:= 280;

 FMySpeedButtonList:= TList.Create;
 for tmpI:= 0 to 2 do begin
   for tmpJ:= 0 to 6 do begin
     tmpSpeedButton:= TMySpeedButton.Create(self);
     tmpSpeedButton.Parent:= self;
     tmpSpeedButton.AllowAllUp:= true;
     tmpSpeedButton.GroupIndex:= tmpIndx;
     tmpSpeedButton.Down:= true;
     tmpSpeedButton.Glyph.Assign(GlyphDown);
     tmpSpeedButton.Col:= tmpI;
     tmpSpeedButton.Row:= tmpJ;
     FMySpeedButtonList.Add(tmpSpeedButton);
     Inc(tmpIndx);
   end;
 end;
end;

procedure TPanelEx.SetGlyphDown(aGlyphDown: TBitmap);
 var tmpI: integer;
begin
 FGlyphDown.Assign(aGlyphDown);
 for tmpI:= 0 to FMySpeedButtonList.Count-1 do begin
   if (TMySpeedButtonList(FMySpeedButtonList.Items[tmpI]).Down) then
     TMySpeedButtonList(FMySpeedButtonList.Items[tmpI]).Glyph.Assign(aGlyphDown);
 end;
end;

procedure TPanelEx.SetGlyphUndown(aGlyphUndown: TBitmap);
 var tmpI: integer;
begin
 FGlyphUndown.Assign(aGlyphUndown);
 for tmpI:= 0 to FMySpeedButtonList.Count-1 do begin
   if not (TMySpeedButtonList(FMySpeedButtonList.Items[tmpI]).Down) then
     TMySpeedButtonList(FMySpeedButtonList.Items[tmpI]).Glyph.Assign(aGlyphUndown);
 end;
end;

function TPanelEx.GetGlyphDown: TBitmap;
begin
 result:= FGlyphDown;
end;

function TPanelEx.GetGlyphUndown: TBitmap;
begin
 result:= FGlyphUndown;
end;


 
siriusP   (2004-04-20 17:44) [1]

Ну что, все кинули?



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: -0.971 c
14-1081961623
Fay
2004-04-14 20:53
2004.04.11
Что случилось с орешником?


3-1081389531
Unk
2004-04-08 05:58
2004.04.11
MIDAS, Oracle, передача в BLOB через параметр


3-1081797714
Mishenka
2004-04-12 23:21
2004.04.11
Можно ли определить была ли запись в таблицу?


14-1079698818
YurikGl
2004-03-19 15:20
2004.04.11
У меня частенько форум выдет следующее....


7-1075557969
juiceman
2004-01-31 17:06
2004.04.11
запуск в авторане




   Наверх