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

•  DeLiKaTeS Tetris (Тетрис)  153

•  TDictionary Custom Sort  3 334

•  Fast Watermark Sources  3 085

•  3D Designer  4 844

•  Sik Screen Capture  3 337

•  Patch Maker  3 550

•  Айболит (remote control)  3 655

•  ListBox Drag & Drop  3 012

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

•  Графические эффекты  3 939

•  Рисование по маске  3 244

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

•  Canvas Drawing  2 748

•  Рисование Луны  2 576

•  Поворот изображения  2 185

•  Рисование стержней  2 168

•  Paint on Shape  1 568

•  Генератор кроссвордов  2 233

•  Головоломка Paletto  1 767

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

•  Пазл Numbrix  1 685

•  Заборы и коммивояжеры  2 056

•  Игра HIP  1 282

•  Игра Go (Го)  1 230

•  Симулятор лифта  1 474

•  Программа укладки плитки  1 216

•  Генератор лабиринта  1 547

•  Проверка числового ввода  1 364

•  HEX View  1 497

•  Физический маятник  1 358

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Доступ к защищенным свойствам



Оформил: DeeCo

{*** It is not always necessary to write a new class when you miss the properties you need ***}

 { 
  Let's say, you writing a program with some standard controls on it's form. 
  One of the components is a TProgressBar. 
  All components, except the progressbar, are yellow (brrrr!!!) 
  but it is not possible to change the color of the progressbar the normal way. 
  There are three things that you can do: 

  1. Leave it this way 
  2. Write a new component 
  3. Try to use WinAPI 

  OR try this: 
}

 // Put this on top of your unit 
type
  TAccessControl = class(TWinControl)
    public
     property Color;
  end;

 // and put into TForm1.FormCreate() the following code: 

  TAccessControl(MyProgressBar).Color:= clYellow;

 { 
  This is possible because TwinControl is the immediate ancestor. 
  There is also another trick to give a existing class more functionality 
  without the need of creating a new component, for example: 
}

 type
  // Just a few lines of code and your TLabel 
 // components on the form has more 
 // functionality without writing a new class 
 TLabel = class(stdctrls.TLabel)
  public
    procedure SayHello();
  end;

  // ... 
procedure TLabel.SayHello();
 begin
   ShowMessage( 'I just want to say hello (and not hello world!)');
 end;


 // As you know the Custom version of a class does not 
// publish all it's properties, so you can do it the same way as with TLabel. 

type
  TTheBaseClass = class(UnitName.TTheBaseClass)
  public
    property Align;
    property Color;
    property YourProp;
    {etc etc}
  end;

 { 
  NOTES: 
  - You can never add new published properties when controls properties are stored 
    in the DFM file (on a form) 
  - You can put modified classes into another unit file so that you can add it 
    AS THE LAST UNIT to the uses clause. 

  I hope you find it usable. 
}







Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте