Let your window adapt to various resolutions

xiaoxiao2021-03-14  206

Suppose you designed at 800 * 600 resolution, the first step: INPLEMentationConst screenwidth: longint = 800; {i designed my form in 800x600 mode.} ScreenHeight: longint = 600;

{$ R * .dfm}

procedure TForm1.FormCreate (Sender: TObject); begin scaled: = true; if (screen.width <> ScreenWidth) then begin height: = longint (height) * longint (screen.height) div ScreenHeight; width: = longint (width * longint (screen.width) Div screenwidth; screen.width, screenwidth; end;

Next, let each sub-control font change to the appropriate size: Type Tfooclass = Class (tcontrol); {NEEDED TO GET AT Protected} {font property}

Var i: integer; begin for i: = controlcount - 1 Downto 0 do tfooclass (Controls [i]). font.size: = (NewFormWidth Div OldFormWidth) * TFOCLASS (Controls [i]). font.size;

转载请注明原文地址:https://www.9cbs.com/read-129443.html

New Post(0)