Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2008.11.30;
Скачать: CL | DM;

Вниз

Вопрос об OnClick компонента CheckBox.   Найти похожие ветки 

 
DJones   (2008-10-22 09:50) [0]

Насколько я понимаю, данное событие срабатывает при изменении свойства checked ( не нажатием мыши, из обработчика другого компонента)... Возможно ли обойти это, т е чтобы изменение  checked мышью вызывало OnClick, а изменение значение Checked  в коде  - нет...?


 
DJones   (2008-10-22 10:05) [1]

я вот решил в обработчике Onclick выполнять определенные действия только когда checkBox.tag = 0, а там где меняю checked - вмеменно меняю тег до 1 например... не знаю правильно ли...


 
Ega23 ©   (2008-10-22 10:25) [2]


> я вот решил в обработчике Onclick выполнять определенные
> действия только когда checkBox.tag = 0, а там где меняю
> checked - вмеменно меняю тег до 1 например... не знаю правильно
> ли...


ну как вариант. Я бы немного по-другому сделал - менял бы обработчик на nil, а потом восстанавливал бы его адрес.


 
Vlad Oshin ©   (2008-10-22 10:26) [3]

работает правильно - значит правильно

+

type
 TForm1 = class(TForm)
   CheckBox1: TCheckBox;
   Button1: TButton;
   procedure CheckBox1Click(Sender: TObject);
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

 tcb = class(TButtonControl);

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 tcb(CheckBox1).ClicksDisabled := true;
 CheckBox1.Checked := not CheckBox1.Checked;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
 if CheckBox1.Checked
  then  ShowMessage("Da")
  else  ShowMessage("Net");
end;


 
brother ©   (2008-10-22 10:27) [4]

я не понял, в чем проблемма?


 
Vlad Oshin ©   (2008-10-22 10:35) [5]

procedure TForm1.Button1Click(Sender: TObject);
begin
// tcb(CheckBox1).ClicksDisabled := true; //срабатывает CheckBox1Click
 CheckBox1.Checked := not CheckBox1.Checked;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
 if CheckBox1.Checked
  then  ShowMessage("Da")
  else  ShowMessage("Net");
end;


 
Ega23 ©   (2008-10-22 10:42) [6]


> я не понял, в чем проблемма?


автор хочет странного.


 
Правильный$Вася   (2008-10-22 11:23) [7]

Usually OnClick occurs when the user presses and releases the left mouse button with the mouse pointer over the control. This event can also occur when

The user selects an item in a grid, outline, list, or combo box by pressing an arrow key.
- The user presses Spacebar while a button or check box has focus.
- The user presses Enter when the active form has a default button (specified by the Default property).
- The user presses Esc when the active form has a cancel button (specified by the Cancel property).
- The user presses the accelerator key for a button or check box. For example, if the value of the Caption property of a check box is "&Bold", the B is underlined at runtime and the OnClick event of the check box is triggered when the user presses Alt+B.
- The Checked property of a radio button is set to true.
- The value of the Checked property of a check box is changed.
- The Click method of a menu item is called.
- For a form, an OnClick event occurs when the user clicks a blank area of the form or on a disabled component.



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

Текущий архив: 2008.11.30;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.014 c
8-1187446480
исследователь
2007-08-18 18:14
2008.11.30
Аналоговые часы


2-1224824692
Quart
2008-10-24 09:04
2008.11.30
Datafield в cxDBImage


2-1224221423
Sergey2
2008-10-17 09:30
2008.11.30
Прокрутка гиф-анимации в отдельном потоке при выполнении задачи


15-1222358569
Real
2008-09-25 20:02
2008.11.30
Почему Microsoft игнорирует Delphi?


3-1210573854
kadr
2008-05-12 10:30
2008.11.30
Оптимизация запроса