Вверх ↑
Разработчик
Ответов: 26200
Рейтинг: 2137
#1: 2022-01-15 13:31:52 ЛС | профиль | цитата
andrestudio писал(а):
сейчас у тебя должно работать

Да, работает, отлично работает. И сплиттер отрабатывает нормально (меня поразило, как ты так точно синхронизировал параметры сплиттеров). Все же надо отказываться от Constraints для всех контролов и оставить их только для формы.
Я вообще отказался от внешнего метода и все перетащил в обработчик. Вряд ли метод SetAnchors где-то еще понадобится.
Вот вызов сообщения установки Anchors:
    WM_WINDOWPOSCHANGED:
    begin
(*
      if (Control.MinWidth <> 0) and (Control.Width < Control.MinWidth) then Control.Width := Control.MinWidth;
      if (Control.MaxWidth <> 0) and (Control.Width > Control.MaxWidth) then Control.Width := Control.MaxWidth;
      if (Control.MinHeight <> 0) and (Control.Height < Control.MinHeight) then Control.Height := Control.MinHeight;
      if (Control.MaxHeight <> 0) and (Control.Height > Control.MaxHeight) then Control.Height := Control.MaxHeight;
*)
      if (Control.ChildCount <> 0) and (fLayout = nil) then 
        for i := 0 to Control.ChildCount - 1 do
          if (Control.Children[i].Align = caNone) then
            Sendmessage(Control.Children[i].Handle, US_SETANCHORS, 0, 0);
      Control.Update;
    end;
А вот, собственно, и отработка сообщения Anchors:
//
//!!! Код предложен andrestudio
//
    US_SETANCHORS:
    begin
      if _prop_akRight then
        if not _prop_akLeft then
          SetWindowPos(Control.Handle, 0, Control.Parent.Width - (fDefWidth + fDefRight), Control.Top, fDefWidth, Control.Height, SWP_NOZORDER)
        else
          SetWindowPos(Control.Handle, 0, fDefLeft, Control.Top, Control.Parent.Width - (fDefLeft + fDefRight), Control.Height, SWP_NOZORDER);

      if _prop_akBottom then
        if not _prop_akTop then
          SetWindowPos(Control.Handle, 0, Control.Left, Control.Parent.Height - (fDefHeight + fDefBottom), Control.Width, fDefHeight, SWP_NOZORDER)
        else
          SetWindowPos(Control.Handle, 0, Control.Left, Control.Top, Control.Width, Control.Parent.Height - (fDefTop + fDefBottom), SWP_NOZORDER);
    end;
  end;
карма: 22

0
Редактировалось 3 раз(а), последний 2022-01-15 13:37:58