Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.01.21;
Скачать: CL | DM;

Вниз

Form1.ScaleBy   Найти похожие ветки 

 
Maloric   (2006-04-08 13:14) [0]

Добрый день!
На Vcl есть функция масштабирования формы
Например:

  iPer:=Round(((ScreenWidth-800)/800)*100)+100;
  xForm.ScaleBy(iPer,100);

Есть ли в KOL что-нибудь подобное?


 
ECM ©   (2006-04-08 14:07) [1]

Нет...
Но никто не запрещает реализовать  Вам это самостоятельно
:)


 
thaddy   (2006-04-08 14:48) [2]


procedure ChangeScaleSimple(Control:Pcontrol; M, D: integer);
var
X, Y, W, H, I: integer;
R:trect;
begin
if M <> D then
with Control^ do
begin
    if Childcount > 0 then
      for i:=0 to pred(childcount) do
        ChangescaleAll(Children[i],M,D);
    R:=Boundsrect;
    X := MulDiv(r.Left, M, D);
    Y := MulDiv(r.Top, M, D);
    W := MulDiv(r.right, M, D);
    H := MulDiv(r.bottom, M, D);
    Boundsrect:=Makerect(x,y,w,h);
    Font.FontHeight := MulDiv(Font.FontHeight, M, D);
end;
end;


 
thaddy   (2006-04-08 14:50) [3]

Sorry, here"s the proper code:

type
TScalingFlags = set of (sfLeft, sfTop, sfWidth, sfHeight, sfFont);

procedure ChangeScale(Control:Pcontrol; M, D: integer; Flags:TScalingFlags =[sfLeft,sfTop, sfWidth, sfHeight, sfFont]; RecurseChildren:boolean=true);
var
 X, Y, W, H, I: integer;
begin
 if M <> D then
 with Control^ do
 begin
    if RecurseChildren then
      if Childcount > 0 then
        for i:=0 to pred(childcount) do
          Changescale(Children[i],M,D);
   if sfLeft in Flags then
     X := MulDiv(Left, M, D) else
     X := Left;
   if sfTop in Flags then
     Y := MulDiv(Top, M, D) else
     Y := Top;
   if sfWidth in Flags then
     if sfLeft in Flags then
       W := MulDiv(Left + Width, M, D)  else
       W := MulDiv(Width, M, D)
   else W := Width;
   if sfHeight in Flags then
     if sfHeight in Flags then
       H := MulDiv(Top + Height, M, D) else
       H := MulDiv(Top, M, D )
   else H := Height;
   BoundsRect:=Makerect(X, Y, W, H);
   if sfFont in Flags then
     Font.Fontheight:= MulDiv(Font.FontHeight, M, D);
 end;
end;

procedure ChangeScaleSimple(Control:Pcontrol; M, D: integer);
var
X, Y, W, H, I: integer;
R:trect;
begin
if M <> D then
with Control^ do
begin
    if Childcount > 0 then
      for i:=0 to pred(childcount) do
        ChangescaleAll(Children[i],M,D);
    R:=Boundsrect;
    X := MulDiv(r.Left, M, D);
    Y := MulDiv(r.Top, M, D);
    W := MulDiv(r.right, M, D);
    H := MulDiv(r.bottom, M, D);
    Boundsrect:=Makerect(x,y,w,h);
    Font.FontHeight := MulDiv(Font.FontHeight, M, D);
end;
end;


 
thaddy   (2006-04-08 14:51) [4]

The first code is simpler and works if you change  ChangescaleAll to ChangeScaleSImple.


 
Maloric   (2006-04-08 15:20) [5]

Спасибо, я так и думал, просто вдруг такая функция уже есть, вот и спросил.


 
thaddy   (2006-04-08 15:27) [6]

Yes, I knwo. I have written it;) And I have posted it before.

For completeness M = muliplier D = divisor, so ChangeSCaleSimple(Form1,75,100); Scales to 75%



Страницы: 1 вся ветка

Текущий архив: 2007.01.21;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.056 c
4-1157886409
Beglec
2006-09-10 15:06
2007.01.21
Подсчет страниц печати на принтере


1-1164787537
DVM
2006-11-29 11:05
2007.01.21
Сменить вид указателя мыши при нажатии на левую кнопку.


1-1164730634
Алена
2006-11-28 19:17
2007.01.21
метод TTimer


15-1166810910
RL69
2006-12-22 21:08
2007.01.21
Блокнот


2-1167342503
Bolt
2006-12-29 00:48
2007.01.21
Как сделать что бы дочерняя форма открывалась как Dialog