Главная страница
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.041 c
3-1078985177
Janbolat
2004-03-11 09:06
2004.04.11
Печать


9-1068311603
MrAngel
2003-11-08 20:13
2004.04.11
glVertexPointerExt в OpenGL.pas отсутствует...


7-1080029027
Аноним
2004-03-23 11:03
2004.04.11
MSDN -> Delphi


3-1079361439
ceval
2004-03-15 17:37
2004.04.11
Помоготе разобраться c IndexFieldNames


11-1067182629
Revolter
2003-10-26 18:37
2004.04.11
как сделать хинт в роли оповещающих сообщений?