Delphi:窗體自適應屏幕分辨率(根據預設值的比例改變)


delphi 程序適應屏幕分辨率,先在表單單元的Interface部分定義兩個常量,
表示設計時的屏幕的寬度和高度(以像素為單位)。
在表單的Create事件中先判斷 當前分辨率是否與設計分辨率相同,
如果不同,調用表單的SCALE過程重新能調整表單中控件的寬度和高度。
Const   Orignwidth=800;   Orignheight=600;
 
procedure TForm1.FormCreate(Sender:TObject);
begin  
  scaled:=true;  
  if (screen.width<>orignwidth) then  
  begin    
    height:=longint(height)*longint(screen.height)div orignheight; 
    width:=longint(width)*longint(screen.width)div orignwidth;    
    scaleby(screen.width,orignwidth);  
  end;
end;
 
http://blog.csdn.net/cmdasm/article/details/45324559


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM