Вверх ↑
Ответов: 2193
Рейтинг: 673
#1: 2019-05-30 14:35:36 ЛС | профиль | цитата
Netspirit, nesco, давайте уточним мы подгоняем doCenterPos под конкретную задачу для fox-video или будем учитывать чтоб:
sla8a писал(а):
корректно работала как минимум такая схема:

А панель тоже в центре группы элементов?
Add(MainForm,15464483,448,175)
{
Width=447
Height=337
Position=1
Point(onResize)
Point(onMove)
link(onCreate,8832083:doWork1,[(487,195)])
link(onResize,8832083:doWork2,[])
link(onMove,8832083:doWork3,[(487,209)])
}
Add(ChildGroupBox,3090827,504,196)
{
}
BEGIN_SDK
Add(EditMulti,4145507,21,21)
{
WorkCount=1
Width=608
Height=417
link(doWork1,7970121:doEvent1,[(105,27)(105,69)])
}
Add(GroupBox,10199545,189,63)
{
Left=10
Top=5
Width=228
Height=213
Point(doCenterPos)
}
Add(ChildPanel,13219045,189,126)
{
}
BEGIN_SDK
Add(EditMulti,6041293,21,21)
{
WorkCount=1
link(doWork1,8499161:doCenterPos,[(101,27)(101,125)])
}
Add(Panel,8499161,182,112)
{
Left=85
Top=20
Height=175
Point(doCenterPos)
}
END_SDK
Add(Hub,7970121,126,63)
{
link(onEvent1,10199545:doCenterPos,[])
link(onEvent2,13219045:doWork1,[(168,76)(168,132)])
}
END_SDK
Add(HubEx,8832083,483,196)
{
link(onEvent,3090827:doWork1,[])
}

--- Добавлено в 2019-05-30 14:57:11

Могу предложить такой вариант:

procedure THIWin._work_doCenterPos;
begin
if Assigned(FParent) then
if GetParent(Control.Handle) = FParent.Handle then
begin
if FParent = Control.ParentForm then
begin//родитель форма
Control.Left := (FParent.ClientWidth - Control.Width) div 2;
Control.Top := (FParent.ClientHeight - Control.Height) div 2;
end
else
begin//родитель контрол
Control.Left := (FParent.Width - Control.Width) div 2;
Control.Top := (FParent.Height - Control.Height) div 2;
end
end
else
begin//дочерняя форма
Control.Left := max((FParent.Left + (FParent.Width - Control.Width) div 2), 0);
Control.Top := max((FParent.Top + (FParent.Height - Control.Height) div 2), 0);
end
else
begin//форма
Control.Left := (ScreenWidth - Control.Width) div 2;
Control.Top := (ScreenHeight - Control.Height) div 2;
end;
end;
карма: 10

0
Редактировалось 2 раз(а), последний 2019-05-30 14:57:11