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

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

•  TDictionary Custom Sort  3 307

•  Fast Watermark Sources  3 057

•  3D Designer  4 810

•  Sik Screen Capture  3 307

•  Patch Maker  3 524

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

•  ListBox Drag & Drop  2 985

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

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

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

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

•  Canvas Drawing  2 726

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

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

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

•  Paint on Shape  1 562

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

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

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

•  Пазл Numbrix  1 678

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

•  Игра HIP  1 274

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

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

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

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

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

•  HEX View  1 486

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

 
скрыть


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

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



Delphi Sources

Изменить Z-порядок ваших контролов во время выполнения программы



Оформил: DeeCo

{ 
  Sometimes you want to change the order of your controls during runtime. 
  Usually you only can send them all the way to the front (Control.BringToFront) or 
  send them all the way back (Control.SendToBack). 

  The following procedure will help you moving a control just one position for or back. 
  This is especially useful when using vector graphis or similar applications. 

  The procedure takes the control to be moved as the first parameter. 
  The direction is the second parameter (True brings the control one step up, 
  False sends it one step back). 

  Internally, this procedure works with SendToBack and BringToFront too, however, 
  it creates an order list first and pushes the other controls as well. 
}

 procedure ChangeControlZOrder(Sender: TObject; MoveUp: Boolean = True);
 var
   I, Curr: Integer;
   Control: TControl;
   List: TList;
 begin
   if Sender is TControl then
   begin
     // only components of type TControl and descendends 
    // work 
    Control := Sender as TControl;
     // has no parent, cannot move ;-) 
    if Control.Parent = nil then
       // quit 
      Exit;
     // determine position in z-order 
    Curr := -1;
     for I := 0 to Pred(Control.Parent.ControlCount) do
       if Control.Parent.Controls[I] = Sender then
       begin
         Curr := I;
         Break;
       end;
     if Curr < 0 then
       // position not found, quit 
      Exit;
     List := TList.Create;
     try
       if MoveUp then
       begin
         for I := Curr + 2 to Pred(Control.Parent.ControlCount) do
           // load other controls in group 
          List.Add(Control.Parent.Controls[I]);
         Control.BringToFront;
         for I := 0 to Pred(List.Count) do
           // move other controls to front, too 
          TControl(List[I]).BringToFront;
       end else begin
         for I := 0 to Curr - 2 do
           // load other controls in group 
          List.Add(Control.Parent.Controls[I]);
         Control.SendToBack;
         for I := Pred(List.Count) downto 0 do
           // move other controls to back, too 
          TControl(List[I]).SendToBack;
       end;
     finally
       List.Free;
     end;
   end;
 end;




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

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




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

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