Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 447

•  TDictionary Custom Sort  6 479

•  Fast Watermark Sources  6 272

•  3D Designer  9 220

•  Sik Screen Capture  6 609

•  Patch Maker  6 992

•  Айболит (remote control)  6 995

•  ListBox Drag & Drop  5 864

•  Доска для игры Реверси  97 039

•  Графические эффекты  7 193

•  Рисование по маске  6 489

•  Перетаскивание изображений  5 362

•  Canvas Drawing  5 739

•  Рисование Луны  5 449

•  Поворот изображения  4 978

•  Рисование стержней  3 535

•  Paint on Shape  2 803

•  Генератор кроссвордов  3 668

•  Головоломка Paletto  2 959

•  Теорема Монжа об окружностях  3 762

•  Пазл Numbrix  2 481

•  Заборы и коммивояжеры  3 166

•  Игра HIP  2 132

•  Игра Go (Го)  2 066

•  Симулятор лифта  2 438

•  Программа укладки плитки  2 111

•  Генератор лабиринта  2 583

•  Проверка числового ввода  2 262

•  HEX View  2 590

•  Физический маятник  2 202

 
скрыть

Изменить поведение при нажатии для TRadioButton или TComboBox



Оформил: DeeCo

// Q: It appears that programatically setting Item.Index for the Radio Button 
// fires the onClick event.  It also appears  doing the same for the 
// ComboBox does NOT fire the OnClick event. Does another property the two 
// control effect this behavior. 

// A: No, it is caused by the way Windows sends the notifications that fire the 
// event when the control state is changed by a program action. 

// Q: I have an instance where I need each of 
// the control to exhibit the opposite behavior. 

// A: For a TRadiobutton you can disconnect the OnClick handler, change the 
// state, then reconnect the handler. 

procedure ChangeRadiobuttonState(ARadiobutton: TRadiobutton;
   checkit: Boolean);
 var
   oldhandler: TNotifyEvent;
 begin
   oldhandler := ARadiobutton.Onclick;
   ARadiobutton.Onclick := nil;
   ARadiobutton.Checked := checkit;
   ARadiobutton.OnClick := oldhandler;
 end;


 // To make the combobox "click" after setting the item index simply call its 
// Click method. The control inherits this method from TControl, but it is 
// protected. So you need a bit of hoop-jumping: 

Type
   TComboCracker = class(TCombobox);

 procedure SetComboboxIndex(ACombobox: TCombobox; Index: Integer);
 begin
   ACombobox.ItemIndex := Index;
   TCombocracker(ACombobox).Click;
 end;