DeWeb 电脑和手机动态适配
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为可视区的宽高,不包括了滚动条的宽度
`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;
`
最新文章
- XidianOJ 1195 Industry of Orz Pandas
- GCD XOR, ACM/ICPC Dhaka 2013, UVa12716
- js根据生日计算出年龄
- HTML---6 运算符,类型转换
- YII Framework学习教程-YII的国际化
- ACM——线性表操作
- C# 导入导出excel文件案例
- poj 2455 二分+最大流
- CSS常见布局解决方案
- 第三篇:爬虫框架 - Scrapy
- 【问题解决方案】下载GitHub里的单个文件
- shelve 模块
- 20180426 Linq to excel
- JAVA程序测试感受
- vue 教程
- 文件路径、File协议、FTP协议、Http协议之间简单的区别
- MCS锁和CLH锁
- TCP\UDP客户—服务器程序设计基本框架流程图
- WPF DataTrigger的两个用法
- java MD5 并发
热门文章
- 【PHP数据结构】链表的相关逻辑操作
- Nginx系列(7)- Nginx安装 | Linux
- jmeter监控linux服务器资源
- php 实现字符串最大子串长度
- Centos7.6安装python3.6.8
- Zend Studio 配置SVN并导入SVN项目
- 定要过python二级选择题二套
- Hive On Spark保姆级攻略
- 一文了解MySQL性能测试及调优中的死锁处理方法,你还看不明白?
- __str__ __repr__区别