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

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

•  TDictionary Custom Sort  3 318

•  Fast Watermark Sources  3 065

•  3D Designer  4 825

•  Sik Screen Capture  3 321

•  Patch Maker  3 536

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

•  ListBox Drag & Drop  2 996

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

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

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

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

•  Canvas Drawing  2 735

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

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

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

•  Paint on Shape  1 564

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

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

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

•  Пазл Numbrix  1 682

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

•  Игра HIP  1 279

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

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

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

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

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

•  HEX View  1 490

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

 
скрыть


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

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



Delphi Sources

Сворачивание, разворачивание и закрытие компонентов во время выполнения



Оформил: DeeCo

{ 

 This program try to show something at least interesting about those components 
 on the form. You'll see that by the fact they're descendant of TWinControl they 
 can react like a Window. I mean they can be maximized, minimized and so on. 
 If you see a control that not respond to our commands it's because it doesn't 
 descend from TWinControl. I didn't try to deal with them. Well. I believe this 
 program is an open door to great ideas. There's a lot of components that could 
 take advantages of this to manipulate controls on the form. You know a long journey 
 starts on the first step. Here it is. 
 Show me anything great you could do out of these ideas. 
 Good work. 

 Babak Sateli 
 babak_sateli@yahoo.com 

}


 unit MessComps;

 interface

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

 type
   TMessing = class(TForm)
     Menu: TMainMenu;
     Options: TMenuItem;
     Minimize: TMenuItem;
     Restore: TMenuItem;
     Hide: TMenuItem;
     Show: TMenuItem;
     N2: TMenuItem;
     Close: TMenuItem;
     Exit_: TMenuItem;
     CloseProgram: TMenuItem;
     Maximize: TMenuItem;
     Memo: TMemo;
     Move: TMenuItem;
     ChangeSize: TMenuItem;
     N1: TMenuItem;
     N3: TMenuItem;
     Target: TMenuItem;
     procedure Procede(Sender: TObject);
     procedure TargetClick(Sender: TObject);
   end;

 var
   Messing: TMessing;
   n: Integer;
   AllOfThem: Boolean = True;

 implementation
 {$R *.DFM}

 procedure TMessing.Procede(Sender: TObject);
 var
   n, Tag: Integer;
   T: TComponent;
   ParentClass: TClass;
   OkToProcede: boolean;
   Comando: Word;
   HasTheFocus: Boolean;
 begin
   // As the menu itens do pratically the same thing we directed them all to here. 
  // Their tag properties are different so we could know who called us. 
  // Save this. We'll need it 
  Tag := (Sender as TMenuItem).Tag;
   case (Sender as TMenuItem).Tag of
     // Oh! You just click options but you're already here. You didn't choose one 
    // yet so exit. 
    0: Exit;
     // Now we have the options. Change comando accordingly to reflect our option. 
    1: COMANDO := SW_MINIMIZE;
     2: COMANDO := SW_MAXIMIZE;
     3: COMANDO := SW_RESTORE;
     4: COMANDO := SW_HIDE;
     5: COMANDO := SW_SHOW;
     6: COMANDO := SC_SIZE;
     7: COMANDO := SC_MOVE;
     8: COMANDO := SC_CLOSE;
     9: Application.Terminate;
   end;
   // Now we know the command we are ready to procede.. 
  // So we start looking for the components this form has. 
  for n := 1 to ComponentCount do
   // Well componentCount starts with 1 
  begin
     // but ComponentsList starts with 0 (zero) so we make some adjustment 
    T := Components[n - 1];
     // Now we have the component in our T variable and can ask a few questions 
    ParentClass := T.ClassParent;
     // We want to know its ClassParent. 
    OkToProcede := ParentClass = TWinControl;
     // if it is descendant of TWinControl then it's ok to procede. 
    while (ParentClass  nil) and (OkToProcede = False) do
     begin
       // Oh no! Not yet. Maybe it descends of a lower class that is 
      // descendant of TWinControl. So we keep going back in its "genealogical" 
      // tree to see if we can find TWinControl back there somewhere or get to nil. 
      OkToProcede := ParentClass = TWinControl;
       ParentClass := ParentClass.Classparent;
     end;
     // if we got to nil and didn't find TWinControl then we have nothing to do 
    // this component doen't accept our kinda of commands. 
    if OkToProcede then
     begin
       // Does it has the focus? 
      HasTheFocus := (T as TWinControl).Focused;
       // If not AllOfThem and not has the focus so we break to the next one. 
      if (not AllOfThem) and (not HasTheFocus) then  Continue;
       if Tag then
         // There no SC_SIZE or SC_MOVE or SC_CLOSE command in here so we have to apart. 
        ShowWindow((T as TWinControl).Handle, COMANDO)
       else
         //  CloseWindow((T as TWinControl).Handle ); Doesn't work. It minimize them. 
        //  But this one bellow works. It's possible to show them after closed but 
        //  the controls loose some of their properties. Methinks it's dangerous 
        (T as TWinControl).Perform(WM_SYSCOMMAND, COMANDO, 0);
     end;
   end;
 end;

 // Changing our target 
procedure TMessing.TargetClick(Sender: TObject);
 begin
   if (Sender as TMenuItem).Tag = 40 then
   begin
     (Sender as TMenuItem).Caption := 'Target: the focused one';
     (Sender as TMenuItem).Tag := 41;
     AllofThem := False;
   end
    else
   begin
     (Sender as TMenuItem).Caption := 'Target: all components';
     (Sender as TMenuItem).Tag := 40;
     AllofThem := True;
   end;
 end;

 end.




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

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




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

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