Цитата:
Сообщение от Alex7
Здравствуйте, накидал код:
Код:
procedure TForm1.SpeedButton3MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ilBtnState.GetBitmap(1, SpeedButton3.Glyph);
if ilBtnState.GetBitmap(1, SpeedButton3.Glyph) then Edit1.Text := FloatToStr(10);
end;
procedure TForm1.SpeedButton3MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ilBtnState.GetBitmap(0, SpeedButton3.Glyph);
if ilBtnState.GetBitmap(1, SpeedButton3.Glyph) then Edit1.Text := FloatToStr(10);
if ilBtnState.GetBitmap(0, SpeedButton3.Glyph) then Edit1.Text := FloatToStr(0);
end;
Нужно чтобы значение edit менялось в зависимости от кнопки SpeedButton, в нажатом состоянии =10, в ненажатом =0
И всё бы хорошо, кнопка фиксируется вкл/выкл, картинка на кнопке меняется, а вот значение edit перескакивает с 10 на 0 когда отпускаю мышку, как победить?
|
--------
Код:
if ilBtnState.GetBitmap(1, SpeedButton3.Glyph) then Edit1.Text := FloatToStr(10);
if ilBtnState.GetBitmap(0, SpeedButton3.Glyph) then Edit1.Text := FloatToStr(0);
-------
Тут ты не проверяешь иконку, которую установил, а устанавливаешь новую. И GetBitmap тебе возвращает True, т.к. успешно её поменял.
Про TSpeedButton.Down тебе уже написали.
Или можешь привязать к свойству Tag кнопки.
А более правильно будет так:
Код:
procedure TForm1.SpeedButton3MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Edit1.Text:='0';
end;
procedure TForm1.SpeedButton3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Edit1.Text:='10';
end;