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

•  TDictionary Custom Sort  3 225

•  Fast Watermark Sources  2 991

•  3D Designer  4 750

•  Sik Screen Capture  3 259

•  Patch Maker  3 467

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

•  ListBox Drag & Drop  2 904

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

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

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

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

•  Canvas Drawing  2 672

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

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

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

•  Paint on Shape  1 525

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

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

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

•  Пазл Numbrix  1 649

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

•  Игра HIP  1 262

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

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

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

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

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

•  HEX View  1 466

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

•  Задача коммивояжера  1 357

 
скрыть


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

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



Delphi Sources

Изменить шрифт всех контролов во время выполнения



Оформил: DeeCo

{ 
Question: 
  What is the most easy way to set a same font name to all controls 
  in project in run time? 

Answer: 
  By default all controls have ParentFont = true, so if you did not change 
  that  for specific controls you could just change the forms Font 
  property, e.g. in code attached to the Screen.OnActiveFormChange event. 
  If you cannot rely on all controls having Parentfont = true you would 
  have to loop over all controls on the form and set the font property for 
  each or at least for those that have ParentFont set to false. You can 
  use the routines from unit TypInfo for that, they allow you to access 
  published properties by name. The code, again sitting in a handler for 
  Screen.onActiveFormChange, would be something like this: 

  ModifyFontsFor( Screen.ActiveControl ); 

where 
}

 procedure ModifyFontsFor(ctrl: TWinControl);
   procedure ModifyFont(ctrl: TControl);
   var
     f: TFont;
   begin
     if IsPublishedProp(ctrl, 'Parentfont')
       and (GetOrdProp(ctrl, 'Parentfont') = Ord(false))
       and IsPublishedProp(ctrl, 'font')
       then begin
       f := TFont(GetObjectProp(ctrl, 'font', TFont));
       f.Name := 'Symbol';
     end;
   end;
 var
   i: Integer;
 begin
   ModifyFont(ctrl);
   for i := 0 to ctrl.controlcount - 1 do
     if ctrl.controls[i] is Twincontrol then
       ModifyFontsfor(TWincontrol(ctrl.controls[i]))
     else
       Modifyfont(ctrl.controls[i]);
 end;

 procedure TForm1.Button2Click(Sender: TObject);
 begin
   Modifyfontsfor(self);
 end;

 // Remember to add TypInfo to your uses clause. 




Похожие по теме исходники

Очередность выполнения процессов




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

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