[ code]
//==================================================================================================
//*** Установка Отображения Кнопок **********
//==================================================================================================
procedure UTF_Button_Enabled(aName: String; aEnabled: Boolean);
begin
for i := 1 to CountButtons do begin
if (aName = Descriptions[i].Name) then begin
case aEnabled of
True: begin
ButtonEnable[i] := False;
ImgGetVisiblePart(ButtonImages[i], LeftBtn[i], TopBtn[i], WidthBtn[i], HeightBtn[i]);
ImgSetVisiblePart(ButtonImages[i], 0, 0, WidthBtn[i], HeightBtn[i]);
if (Descriptions[i].Font.Color = Clr4[i]) then
Descriptions[i].Font.Color := Clr1[i];
end;
False: begin
ButtonEnable[i] := True;
Descriptions[i].Font.Color := Clr4[i];
ImgSetVisiblePart(ButtonImages[i], 0, HeightBtn[i]*3, WidthBtn[i], HeightBtn[i]);
end;
end;
ImgApplyChanges(Descriptions[i].Parent.Handle);
end;
end;
end;
//==================================================================================================
//*** Установка Видимости Кнопок ************
//==================================================================================================
procedure UTF_Button_Visable(aName: String; aVisable: Boolean);
begin
for i := 1 to CountButtons do begin
if (aName = Descriptions[i].Name) then begin
ImgSetVisibility(ButtonImages[i], aVisable);
Descriptions[i].Visible := aVisable;
ImgApplyChanges(Descriptions[i].Parent.Handle);
end;
end;
end;
//==================================================================================================
//*** Установка Выполнения Кнопок ***********
//==================================================================================================
procedure UTF_ButtonEvent(aName: String);
begin
for i := 1 to CountButtons do begin
if (aName = Descriptions[i].Name) then
OnClicksButton(aName);
end;
end;
//==================================================================================================
//*** Установка Текста Кнопок ***************
//==================================================================================================
procedure UTF_Button_SetText(aName, aText: String);
begin
for i := 1 to CountButtons do begin
if (aName = Descriptions[i].Name) then
Descriptions[i].Caption := aText;
end;
end;
//==================================================================================================
//*** Отображение Наведения на Кнопки *******
//==================================================================================================
procedure UTF_Button_MouseLeave(Sender: TObject);
begin
for i := 1 to CountButtons do begin
case Sender of
Descriptions[i]: begin
if not ButtonEnable[i] then begin
Descriptions[i].Font.Color := Clr1[i];
ImgSetVisiblePart(ButtonImages[i], 0, 0, WidthBtn[i], HeightBtn[i]);
ImgApplyChanges(Descriptions[i].Parent.Handle);
end;
end;
end;
end;
end;
//==================================================================================================
//*** Отображение Выполнения Кнопки *********
//==================================================================================================
procedure UTF_Button_MouseEnter(Sender: TObject);
begin
// sndEnter(); /* Звук при наведении */
for i := 1 to CountButtons do begin
case Sender of
Descriptions[i]: begin
if not ButtonEnable[i] then begin
Descriptions[i].Font.Color := Clr2[i];
ImgSetVisiblePart(ButtonImages[i], 0, HeightBtn[i], WidthBtn[i], HeightBtn[i]);
ImgApplyChanges(Descriptions[i].Parent.Handle);
end;
end;
end;
end;
end;
//==================================================================================================
//*** Отображение Нажатия на Кнопки *********
//==================================================================================================
procedure UTF_Button_OnClickButton(Sender: TObject);
begin
// sndCheck(); /* Звук при нажатии */
for i := 1 to CountButtons do begin
case Sender of
Descriptions[i]: begin
if not ButtonEnable[i] then begin
Descriptions[i].Font.Color := Clr3[i];
ImgSetVisiblePart(ButtonImages[i], 0, HeightBtn[i]*2, WidthBtn[i], HeightBtn[i]);
ImgApplyChanges(Descriptions[i].Parent.Handle);
Sleep(100);
Descriptions[i].Font.Color := Clr2[i];
ImgSetVisiblePart(ButtonImages[i], 0, HeightBtn[i], WidthBtn[i], HeightBtn[i]);
ImgApplyChanges(Descriptions[i].Parent.Handle);
Descriptions[i].Top := Descriptions[i].Top*2;
Descriptions[i].Top := Descriptions[i].Top/2;
UTF_ButtonEvent(Descriptions[i].Name);
end;
end;
end;
end;
end;
//==================================================================================================
//*** Создание Кнопок ***********************
//==================================================================================================
procedure UTF_Button_Create(aName: String; aParent: TWinControl; aFilename: String; aLeft, aTop, aWidth, aHeight: Integer; aFontName: String; aFontSize: Integer; aFntStyle: TFontStyles; aText: String; aClr1, aClr2, aClr3, aClr4: TColor; aCursor: TCursor);
begin
CountButtons := CountButtons+1;
LeftBtn[CountButtons] := aLeft;
TopBtn[CountButtons] := aTop;
WidthBtn[CountButtons] := aWidth;
HeightBtn[CountButtons] := aHeight;
Clr1[CountButtons] := aClr1;
Clr2[CountButtons] := aClr2;
Clr3[CountButtons] := aClr3;
Clr4[CountButtons] := aClr4;
ButtonImages[CountButtons] := ImgLoad(aParent.Handle, aFilename, LeftBtn[CountButtons], TopBtn[CountButtons], WidthBtn[CountButtons], HeightBtn[CountButtons], True, True);
Descriptions[CountButtons] := TLabel.Create(nil);
with Descriptions[CountButtons] do begin
Parent := aParent;
SetBounds(LeftBtn[CountButtons], TopBtn[CountButtons]+Round((HeightBtn[CountButtons]-(aFontSize+(aFontSize*0.70))) div 2)+1, WidthBtn[CountButtons], Trunc(aFontSize+(aFontSize*0.70)));
Alignment := taCenter;
AutoSize := False;
Caption := aText;
Cursor := aCursor;
Font.Name := aFontName;
Font.Size := aFontSize;
Font.Style := aFntStyle;
Font.Color := Clr1[CountButtons];
Name := aName;
WordWrap := False;
Transparent := True;
OnClick := @UTF_Button_OnClickButton;
OnMouseEnter := @UTF_Button_MouseEnter;
OnMouseLeave := @UTF_Button_MouseLeave;
end;
ImgSetVisiblePart(ButtonImages[CountButtons], 0, 0, WidthBtn[CountButtons]+2, HeightBtn[CountButtons]);
ImgApplyChanges(Descriptions[CountButtons].Parent.Handle);
end;