Fórum Como colocar um ImageList em um SpeedButton #379406
11/06/2010
0
ou alguem tem um outra ideia para me ajudar ???
Robson Morais
Curtir tópico
+ 0Posts
11/06/2010
Marco Salles
Gostei + 0
12/06/2010
Robson Morais
entao mas alguem teria alguma ideia de como eu poderia fazer isso, pois eu estava pensando aqui em salvar images no banco de dados e ai o usuario buscar essa imagem la...
mas será que ficaria legal ????
Gostei + 0
13/06/2010
Marco Salles
unit uNomeDaSuaUnit;
interface
uses
Controls,Buttons;
Type
TAcao= class
private
class function GetFIndice: Integer;
class procedure SetFIndice(const Value: Integer);
class procedure Execute(cSbn:TSpeedButton; cImageList:TImageList);
property Indice:Integer read GetFIndice Write SetFIndice;
public
class procedure First(cSbn:TSpeedButton;cImageList:TImageList);
class procedure Prior(cSbn:TSpeedButton; cImageList:TImageList);
class procedure Next(cSbn:TSpeedButton; cImageList:TImageList);
class procedure Last(cSbn:TSpeedButton;cImageList:TImageList);
end;
implementation
{$WRITEABLECONST ON}
const
FImageList:TImageList = nil;
FSbn:TSpeedButton = nil;
FIndice:integer = -1;
{$WRITEABLECONST OFF}
{ TAcao }
class procedure TAcao.Execute(cSbn:TSpeedButton; cImageList:TImageList);
begin
cSbn.Glyph:=nil;
// FImageList:= cImageList;
cImageList.GetBitmap(FIndice,cSbn.Glyph);
end;
class procedure TAcao.First(cSbn:TSpeedButton; cImageList:TImageList);
begin
FIndice:=0;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Last(cSbn:TSpeedButton; cImageList:TImageList);
begin
FIndice:=cImageList.Count-1;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Next(cSbn:TSpeedButton; cImageList:TImageList);
begin
if FIndice < cImageList.Count-1 then
FIndice:=FIndice+1;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Prior(cSbn:TSpeedButton; cImageList:TImageList);
begin
if FIndice > 0 then
FIndice:=FIndice - 1;
Execute(cSbn,cImageList);
end;
{****************************************************************************}
class function TAcao.GetFIndice: Integer;
begin
result:=FIndice;
end;
{*********************************************************************************** }
class procedure TAcao.SetFIndice(const Value: Integer);
begin
FIndice:=Value;
end;
end.
procedure TForm3.btnPrimeiroClick(Sender: TObject); begin TAcao.First(SpeedButton1,ImageList1); end; procedure TForm3.btnAnteriorClick(Sender: TObject); begin TAcao.Prior(SpeedButton1,ImageList1); end; procedure TForm3.btnProximoClick(Sender: TObject); begin TAcao.Next(SpeedButton1,ImageList1); end; procedure TForm3.btnUltimoClick(Sender: TObject); begin TAcao.Last(SpeedButton1,ImageList1); end;
Gostei + 0
13/06/2010
Marco Salles
unit uNomeDaSuaUnit;
interface
uses
Controls,Buttons;
Type
TAcao= class
private
class function GetFIndice: Integer;
class procedure SetFIndice(const Value: Integer);
class procedure Execute(cSbn:TSpeedButton; cImageList:TImageList);
property Indice:Integer read GetFIndice Write SetFIndice;
public
class procedure First(cSbn:TSpeedButton;cImageList:TImageList);
class procedure Prior(cSbn:TSpeedButton; cImageList:TImageList);
class procedure Next(cSbn:TSpeedButton; cImageList:TImageList);
class procedure Last(cSbn:TSpeedButton;cImageList:TImageList);
end;
implementation
{$WRITEABLECONST ON}
const
FIndice:integer = -1;
{$WRITEABLECONST OFF}
{ TAcao }
class procedure TAcao.Execute(cSbn:TSpeedButton; cImageList:TImageList);
begin
cSbn.Glyph:=nil;
// FImageList:= cImageList;
cImageList.GetBitmap(FIndice,cSbn.Glyph);
end;
class procedure TAcao.First(cSbn:TSpeedButton; cImageList:TImageList);
begin
FIndice:=0;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Last(cSbn:TSpeedButton; cImageList:TImageList);
begin
FIndice:=cImageList.Count-1;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Next(cSbn:TSpeedButton; cImageList:TImageList);
begin
if FIndice < cImageList.Count-1 then
FIndice:=FIndice+1;
Execute(cSbn,cImageList);
end;
class procedure TAcao.Prior(cSbn:TSpeedButton; cImageList:TImageList);
begin
if FIndice > 0 then
FIndice:=FIndice - 1;
Execute(cSbn,cImageList);
end;
{****************************************************************************}
class function TAcao.GetFIndice: Integer;
begin
result:=FIndice;
end;
{*********************************************************************************** }
class procedure TAcao.SetFIndice(const Value: Integer);
begin
FIndice:=Value;
end;
end.
procedure TForm3.btnPrimeiroClick(Sender: TObject); begin TAcao.First(SpeedButton1,ImageList1); end; procedure TForm3.btnAnteriorClick(Sender: TObject); begin TAcao.Prior(SpeedButton1,ImageList1); end; procedure TForm3.btnProximoClick(Sender: TObject); begin TAcao.Next(SpeedButton1,ImageList1); end; procedure TForm3.btnUltimoClick(Sender: TObject); begin TAcao.Last(SpeedButton1,ImageList1); end;
Gostei + 0
15/06/2010
Robson Morais
SpeedButton1.Glyph.Assign(nil); ImageList1.GetBitmap(0, SpeedButton1.Glyph);
mas a q voce passou vou testar também!
Gostei + 0
15/06/2010
Marco Salles
SpeedButton1.Glyph.Assign(nil); ImageList1.GetBitmap(0, SpeedButton1.Glyph);
mas a q voce passou vou testar também!
class procedure TAcao.Execute(cSbn:TSpeedButton; cImageList:TImageList); begin cSbn.Glyph:=nil; // FImageList:= cImageList; cImageList.GetBitmap(FIndice,cSbn.Glyph); end;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)