Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2004.04.11;
Скачать: [xml.tar.bz2];

Вниз

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

 
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: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]

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


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

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



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

Форум: "Основная";
Текущий архив: 2004.04.11;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.046 c
1-1082554995
Shag
2004-04-21 17:43
2004.05.09
выделение в Excel


7-1079525450
DuchmanSoft
2004-03-17 15:10
2004.05.09
Мою программу закрывает другая программа


3-1081939231
31512
2004-04-14 14:40
2004.05.09
TClientDataSet.ApplyUpdates(0) & TClientDataSet.Refresh


3-1081520702
Наташулечка
2004-04-09 18:25
2004.05.09
Выборка значений


14-1081980627
Мазут Береговой
2004-04-15 02:10
2004.05.09
Анекдоты от науки:





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский