Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2006.01.01;
Скачать: [xml.tar.bz2];

Вниз

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

 
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 вся ветка

Форум: "KOL";
Текущий архив: 2006.01.01;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.48 MB
Время: 0.009 c
14-1133852004
WondeRu
2005-12-06 09:53
2006.01.01
Ищу CSS Tutorial


14-1134027893
syte_ser78
2005-12-08 10:44
2006.01.01
что есть такео ГАДЖЕТ?????


6-1127146757
Express
2005-09-19 20:19
2006.01.01
Socket


8-1122562004
olorint
2005-07-28 18:46
2006.01.01
256 цветов


1-1133505011
denmin
2005-12-02 09:30
2006.01.01
Как в Rave привязать RvRenderRTF1 так чтобы я мог сохранить RTF?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский