的.DFM文件被改变是因为有在Windows注册表中设置两台机器
之间的一些差异 电脑\ HKEY_CURRENT_USER \控制面板\桌面\ WindowMetrics
这是导致边框,标题,窗体标题的原因高度/宽度是不同
如果您运行使用相同的exe文件,你有可能得到不同的结果
高度计算
以下功能//这得到ŧ他窗体标题身高
GetSystemMetrics的(SM_CYCAPTION)
//这得到了表格边框宽度
GetSystemMetrics的(SM_CYFRAME)
//这让窗体MainMenu的高度
GetSystemMetrics的(SM_CYMENU)
这里是一个例如功能,以显示高度计算
function CalcHeightDifference : String;
var iActualHeightDifference : integer;
iCalcHeightDifference : integer;
sInfo : String;
begin
iCalcHeightDifference := 0;
iActualHeightDifference := self.Height - Self.ClientHeight;
//Caption
iCalcHeightDifference := iCalcHeightDifference + GetSystemMetrics(SM_CYCAPTION);
sInfo := ' + Form Caption = ' + inttostr(GetSystemMetrics(SM_CYCAPTION));
//Borders
iCalcHeightDifference := iCalcHeightDifference + GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYFRAME);
sInfo := sInfo + sLineBreak + ' + Border Height(' + inttostr(GetSystemMetrics(SM_CYFRAME)) + ') times two = ' + inttostr(GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYFRAME) );
//Menu
if self.Menu <> nil then begin
iCalcHeightDifference := iCalcHeightDifference + GetSystemMetrics(SM_CYMENU);
sInfo := sInfo + sLineBreak + ' + Form MainMenu = ' + inttostr(GetSystemMetrics(SM_CYMENU));
end;
result := format('Form.ClientHeight=%d', [Self.ClientHeight])
+ sLineBreak
+ format('Form.Height=%d', [Self.Height])
+ sLineBreak
+ format('The Height Difference of %d is made up of', [Self.Height-Self.ClientHeight])
+ sLineBreak
+ sInfo
+ sLineBreak
+ format(' Total(%d)', [iCalcHeightDifference]) ;
end;
宽度计算的解体
//这个获取表格边框宽度
GetSystemMetrics的(SM_CXFRAME)
这里有一个例子函数来显示宽度计算
function CalcWidthDifference : String;
var iActualWidthDifference : integer;
iCalcWidthDifference : integer;
sInfo : String;
begin
iCalcWidthDifference := 0;
iActualWidthDifference := self.Width - Self.ClientWidth;
//Borders
iCalcWidthDifference := GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXFRAME);
sInfo := ' + Border Width(' + inttostr(GetSystemMetrics(SM_CXFRAME)) + ') times Two = ' + inttostr(GetSystemMetrics(SM_CXFRAME)+GetSystemMetrics(SM_CXFRAME));
result := format('Form.ClientWidth=%d', [Self.ClientWidth])
+ sLineBreak
+ format('Form.Width=%d', [Self.Width])
+ sLineBreak
+ format('The Width Difference of %d is made up of', [Self.Width-Self.ClientWidth])
+ sLineBreak
+ sInfo
+ sLineBreak
+ format(' Total(%d)', [iCalcWidthDifference]) ;
end;
这一切都因为我们有两个窗口发展的解体机器是随机更改窗体上的.DFM文件宽度和面板等
我已经包含了一些屏幕截图,从同一个exe文件在不同的机器上运行,以显示宽度不同。如果我想在设计时改变这种形式的东西。DFM文件将具有不同宽度
机1 机2
什么是你的问题,节省? –
我想查看宽度和客户端宽度之间差异的实际值。例如边框尺寸等 – Dangas56
这就是全部?你不是已经在做这个数学吗? 'WidthDiff:= Width - ClientWidth; HeightDiff:= Height - ClientHeight;'或者你还在计算窗口标题区域的非客户端高度? –