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

Вниз

разрешение экрана   Найти похожие ветки 

 
uli   (2005-05-14 06:40) [0]

Уважаемые мастера! Подскажите пожалуйста, как в KOL сделать форму масштабируемой взависимости от разрешения экрана? Есть готовый проект, разработанный на компьютере с разрешением 1024*768, на разрешении 800*600 часть формы обрезается, так как она не входит в экран. Как привести все это в божеский вид?


 
Владимир Кладов   (2005-05-14 09:55) [1]

в OnFormCreate:

if Form.Width > ScreenWidth then Form.Width := Screen.Width; if Form.Height > ScreenHeight then Form.Height := ScreenHeight;

Это всяко лучше чем дожидаться пока система обрежет до 800х600 или 640х480.


 
uli   (2005-05-14 10:20) [2]

большое спасибо за ответ, но меня интересовало несколько другое, не суть важно кто обрежет форму. Есть ли аналог scaled в KOL, т.е. чтоб пропорционально изменить размер формы и всех ее контролов?


 
Владимир Кладов   (2005-05-14 11:40) [3]

нет


 
Thaddy   (2005-05-14 12:10) [4]

// Use only true PControls
// Iterate to all the controls calling this
// M = Delta, D = Divisor i.e: calling with 75,100 scales to 75%
// Note this has less options than the VCL code, but oit uses
//the same mechanism

procedure ChangeScale(Control:Pcontrol; M, D: Integer);
var
 X, Y, W, H: Integer;
 Flags: TScalingFlags;
 R:TRect;
begin
 if M <> D then
 with Control^ do
 begin
     X := MulDiv(Left, M, D);
     Y := MulDiv(Top, M, D);
     W := MulDiv(Left + Width, M, D) - X;
     H := MulDiv(Top + Height, M, D) - Y;
     Control.BoundsRect:=Makerect(X,Y,W,H);
     Font.FontHeight := MulDiv(Font.FontHeight, M, D);
 end;
end;


 
Thaddy   (2005-05-14 12:46) [5]

// Sorry: screen coordinates.
// This is better
procedure ChangeScale(Control:Pcontrol; M, D: Integer);
var
X, Y, W, H, I: Integer;
begin
if M <> D then
with Control^ do
begin
    X := MulDiv(Left, M, D);
    Y := MulDiv(Top, M, D);
    W := MulDiv(left+Width, M, D) - X;
    H := MulDiv(top+Height, M, D) - Y;
    Control.setposition(x,y).Setsize(w,h);
    Font.FontHeight := MulDiv(Font.FontHeight, M, D);
end;
end;


 
Thaddy   (2005-05-14 12:50) [6]

// And Recursive:
procedure ChangeScaleAll(Control:Pcontrol; M, D: Integer);
var
X, Y, W, H, I: Integer;
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);
    X := MulDiv(Left, M, D);
    Y := MulDiv(Top, M, D);
    W := MulDiv(left+Width, M, D) - X;
    H := MulDiv(top+Height, M, D) - Y;
    Control.setposition(x,y).Setsize(w,h);
    Font.FontHeight := MulDiv(Font.FontHeight, M, D);
end;
end;


 
Thaddy   (2005-05-14 13:18) [7]

// 100 times Sorry to you all, but this is better:
procedure ChangeScaleAll(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   (2005-05-14 13:53) [8]

// Complex version with scale and recusion options:
// This is analogous to the VCL
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;


 
Boguslaw Brandys   (2005-05-14 21:08) [9]

Not so important but - how to detect if screen resolution changed during program execution ? This is rare and always could be avoided by requesting application restart, but anyway - is there any method in KOL to detect resolution change ? i can imagine using idle handler but maybe a better solution ?


 
Thaddy   (2005-05-14 21:32) [10]

There is a windows API message that is send if the relolution changes. I don"t know it from memory, but I have used it before. I will add that tomorrow. There is a demo on my website


 
Владимир Кладов   (2005-05-15 19:51) [11]

WM_DISPLAYCHANGE


 
uli   (2005-05-16 06:07) [12]

последний вариант процедуры почему-то не меняет высоты шрифта


 
Thaddy   (2005-05-16 12:16) [13]

Use the second to last or the one on my website: easier and probably all you need www.thaddy.com/scaledemo.zip.


 
uli   (2005-05-17 08:39) [14]

"Данный файл является текстовой HTML-страницей". Не качается, короче


 
Thaddy   (2005-05-17 08:59) [15]

Not with me, I tried. Try this www.thaddy.com/kolindex.htm and download manually


 
Thaddy   (2005-05-17 10:01) [16]

Not with me, I tried. Try this www.thaddy.com/kolindex.htm and download manually



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

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

Наверх




Память: 0.5 MB
Время: 0.057 c
2-1134412154
vpavel
2005-12-12 21:29
2006.01.01
Запрет CTRL+ALT+DEL на XP


14-1133968821
Кручен-Верчен
2005-12-07 18:20
2006.01.01
МАТЕМАТИКА


10-1110787173
YuriyVol
2005-03-14 10:59
2006.01.01
Как корректно открыть csv файл через Excel OLE ?


1-1133680905
Элеонора
2005-12-04 10:21
2006.01.01
GetIconMetaPict


14-1134322425
Yegorchic
2005-12-11 20:33
2006.01.01
Пифагорово дерево