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

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

•  TDictionary Custom Sort  6 659

•  Fast Watermark Sources  6 440

•  3D Designer  9 379

•  Sik Screen Capture  6 771

•  Patch Maker  7 170

•  Айболит (remote control)  7 170

•  ListBox Drag & Drop  6 023

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

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

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

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

•  Canvas Drawing  5 887

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

•  Поворот изображения  5 119

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

•  Paint on Shape  2 921

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

•  Головоломка Paletto  3 065

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

•  Пазл Numbrix  2 548

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

•  Игра HIP  2 249

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

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

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

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

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

•  HEX View  2 670

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

 
скрыть

  Форум  

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

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



Глобальный поиск компонента





unit FindGlob;

interface

uses
  Classes, DsgnIntf, Forms, SysUtils;

function FindGlobalComp (const Name: string;
  List: TComponentList): Boolean;

implementation

function FindGlobalComp (const Name: string;
  List: TComponentList): Boolean;
var
  I, J, InitCount: Integer;
  Form, Comp: TComponent;
begin
  InitCount := List.Count;
  for I := 0 to Screen.FormCount - 1 do
  begin
    Form := Screen.Forms[I];
    if CompareText(Name, Form.Name) = 0 then
      List.Add (Form);
    for J := 0 to Form.ComponentCount - 1 do
    begin
      Comp := Form.Components [J];
      if CompareText(Name, Comp.Name) = 0 then
        List.Add (Comp);
    end;
  end;
  for I := 0 to Screen.DataModuleCount - 1 do
  begin
    Form := Screen.DataModules[I];
    if CompareText(Name, Form.Name) = 0 then
      List.Add (Form);
    for J := 0 to Form.ComponentCount - 1 do
    begin
      Comp := Form.Components [J];
      if CompareText(Name, Comp.Name) = 0 then
        List.Add (Comp);
    end;
  end;
  // true if found
  Result := (List.Count - InitCount) > 0;
end;

end.


unit FindForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  FindGlob, DsgnIntf;

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  Comp: TComponent;
  List: TComponentList;
begin
  ListBox1.Items.Clear;
  List := TComponentList.Create;
  try
    if not FindGlobalComp (Edit1.Text, List) then
      ListBox1.Items.Add ('No components found')
    else
      for I := 0 to List.Count - 1 do
      begin
        Comp := List.Items[I] as TComponent;
        ListBox1.Items.Add (Format (
          '%s (%s): %s (%s)',
          [Comp.Name, Comp.ClassName,
          Comp.Owner.Name, Comp.Owner.ClassName]));
      end;
  finally
    List.Free;
  end;
end;

end.


unit SecondF;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Edit1: TEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.DFM}

end.

Загрузить весь проект





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

Поисковик

Поиск символа

Поиск файлов

Поиск открытых файлов

 

Findup (поиск дублей)

Дейкстра: поиск кратчайшего пути

Расширение компонента TEdit