DeWeb 做多平台适配很方便!

多平台适配代码在OnMouseUp中。

X,Y分别表示当前设备的Width/Height;

Button : mbLeft : 屏幕纵向, mbRight:屏幕横向;

Shift:ssShift, ssAlt, ssCtrl,ssLeft, ssRight,

分别对应0:未知/1:PC/2:Android/3:iPhone/4:Tablet

另外,浏览窗体的

screenWidth可以通过dwGetProp(Self,'screenwidth')得到;

screenHeight可以通过dwGetProp(Self,'screenheight')得到;

innerWidth可以通过dwGetProp(Self,'innerwidth')得到;

innerHeight可以通过dwGetProp(Self,'innerheight')得到;

clientWidth可以通过dwGetProp(Self,'clientwidth')得到;

clientHeight可以通过dwGetProp(Self,'clientheight')得到;

其中:

screenWidth/screenHeight为屏幕分辨率。 注意:移动端为虚拟屏幕分辨率

innerWidth/innerHeight为可视区的宽高,包括了滚动条的宽度

clientWidth/clientHeight为可视区的宽高,不包括了滚动条的宽度

效果:http://www.web0000.com

`procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

var

iInnerW : Integer;

iRowCount : Integer;

iDemo : Integer;

//

oPanel : TPanel;

begin

//Shift:ssShift, ssAlt, ssCtrl,ssLeft, ssRight,

//分别对应0:未知/1:PC/2:Android/3:iPhone/4:Tablet

 if  (ssShift in Shift) or (ssAlt in Shift) then begin
Width := X-30;
iInnerW := StrToIntDef(dwGetProp(Self,'innerwidth'),-1);
//
if iInnerW = -1 then begin
Exit;
end; //
Width := iInnerW; if iInnerW < 1000 then begin
Panel_Inner0.Width := iInnerW;
end else begin
Panel_Inner0.Width := 1000;
end;
Panel_Inner0.Left := (Width - Panel_Inner0.Width) div 2;
//
Panel_Inner1.Width := Panel_Inner0.Width;
Panel_Inner1.Left := Panel_Inner0.Left;
end else begin
if Y>X then begin
//
Width := X; //
Panel_All.Width := X; //
Panel_Inner0.Width := X;
Panel_Inner0.Left := 0;
Panel_Inner1.Width := X;
Panel_Inner1.Left := 0;
Panel_Inner2.Width := X;
Panel_Inner2.Left := 0;
Panel_Inner3.Width := X;
Panel_Inner3.Left := 0; //hide components
Edit_Search.Visible := False;
Button_Search.Visible := False;
Label_FAQs.Visible := False;
StaticText_FAQs.Visible := False;
Label_ContactUs.Visible := False;
StaticText_ContactUs.Visible := False; //label : web develop with delphi
Label_WDWD.Width := X;
Label_WDWD.Font.Size := 18;
Label_WDWD.Caption := 'Web develop with Delphi';
Label_WDWD.Left := 0; //introduce labels
Label_Introduce0.Left := 8;
Label_Introduce1.Left := 8;
Label_Introduce1.Caption := '无需学习HTML/JavaScript/Java/PHP等新知识';
Label_Introduce2.Left := 8; //fee label
Label_Fee.Left := Label_BuyNow.Left + Label_BuyNow.Width; //buttons
Button_Download.Left := 10;
Button_Download.Width := (X-30) div 2;
Button_Download.Caption := 'Download';
Button_BuyNow.Left := Button_Download.Left + 10 + Button_Download.Width;
Button_BuyNow.Width := Button_Download.Width; //demos
iRowCount := X div 180;
Panel_03_Demos.Height := Ceil(gjoDemos.A['items'].Count / iRowCount)*140;
Panel_Inner3.Height := Panel_03_Demos.Height;
for iDemo := 0 to gjoDemos.A['items'].Count-1 do begin
//get the demo panel include image and href(TStaticText)
oPanel := TPanel(FindComponent('Panel_Demo_'+IntToStr(iDemo)));
oPanel.Top := (iDemo div iRowCount) *140;
oPanel.Left := (iDemo mod iRowCount)* 180; end; end;
end;
//set total height
Panel_All.Height := Panel_99_Foot.Top + Panel_99_Foot.Height;
dwSetHeight(self,Panel_All.Height);

end;

`

最新文章

  1. XidianOJ 1195 Industry of Orz Pandas
  2. GCD XOR, ACM/ICPC Dhaka 2013, UVa12716
  3. js根据生日计算出年龄
  4. HTML---6 运算符,类型转换
  5. YII Framework学习教程-YII的国际化
  6. ACM——线性表操作
  7. C# 导入导出excel文件案例
  8. poj 2455 二分+最大流
  9. CSS常见布局解决方案
  10. 第三篇:爬虫框架 - Scrapy
  11. 【问题解决方案】下载GitHub里的单个文件
  12. shelve 模块
  13. 20180426 Linq to excel
  14. JAVA程序测试感受
  15. vue 教程
  16. 文件路径、File协议、FTP协议、Http协议之间简单的区别
  17. MCS锁和CLH锁
  18. TCP\UDP客户—服务器程序设计基本框架流程图
  19. WPF DataTrigger的两个用法
  20. java MD5 并发

热门文章

  1. 【PHP数据结构】链表的相关逻辑操作
  2. Nginx系列(7)- Nginx安装 | Linux
  3. jmeter监控linux服务器资源
  4. php 实现字符串最大子串长度
  5. Centos7.6安装python3.6.8
  6. Zend Studio 配置SVN并导入SVN项目
  7. 定要过python二级选择题二套
  8. Hive On Spark保姆级攻略
  9. 一文了解MySQL性能测试及调优中的死锁处理方法,你还看不明白?
  10. __str__ __repr__区别