Главная страница
    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: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;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.038 c
3-1081744611
Bizon
2004-04-12 08:36
2004.05.09
Checkbox в DBGride


4-1079117587
dkDimon
2004-03-12 21:53
2004.05.09
Восстановление экрана


14-1081932983
Bilio
2004-04-14 12:56
2004.05.09
Помогите разработать систему оценки работы продавцов в магазине


1-1082466625
ss300
2004-04-20 17:10
2004.05.09
Переход от одного поля на другое нажатием на Enter


3-1081778909
Gennadiy
2004-04-12 18:08
2004.05.09
Проблема с запросом в IBQuery





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
Английский Французский Немецкий Итальянский Португальский Русский Испанский