我们有两台不同的开发者机器使用相同的.pas文件
任何时候一个开发人员更改某个表单上的内容.dfm文件中的form.width可以更改
在一台机器上的Form(宽度= 651)和(ClientWidth = 635)
另一台机器Form(宽度= 643)和(ClientWidth = 635)
我想知道为什么(宽度和高度)在表单.dfm文件中发生了变化
我想在运行时看到计算的细分+之间差异的原因
(ClientHeight和Height)和(ClientWidth and Width)
所以if(width = 651)和(ClientWidth = 635)
我如何在运行时检查窗口边框宽度或我需要什么来锻炼这些值之间的差异?
答案 0 :(得分:1)
.DFM文件发生变化的原因是因为两台机器之间的Windows注册表设置存在一些差异
计算机\ HKEY_CURRENT_USER \控制面板\桌面\ WindowMetrics
这导致边框,标题,表格标题高度/宽度不同
如果使用相同的exe运行以下功能,可能会得到不同的结果
高度计算
//这将获得表格标题高度
GetSystemMetrics(SM_CYCAPTION)
//这将获得表格边框宽度
GetSystemMetrics(SM_CYFRAME)
//这将获得Forms 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文件将以不同的宽度保存