Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.04.11;
Скачать: 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 вся ветка

Текущий архив: 2004.04.11;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.036 c
14-1081859772
syte_ser78
2004-04-13 16:36
2004.04.11
Встреча Харьковских мастеров


1-1082456276
Th
2004-04-20 14:17
2004.04.11
Delphi-реализация unix-ф-ции Crypt() (алгоритм DES)


14-1081925766
lehich
2004-04-14 10:56
2004.04.11
книга по WinAPI


1-1082381323
Феликс М.
2004-04-19 17:28
2004.04.11
Печать как из Ворда


3-1081920807
Pako
2004-04-14 09:33
2004.04.11
индексы