2017-06-15 21 views
-1

我们有两个不同的开发人员机器使用相同的.pas文件
任何时候一个开发人员可以在.dfm文件的form.width文件中更改某些内容改变
一个机器形式的调查(宽度= 651)和(ClientWidth = 635)
其它机器表格(宽度= 643)和(ClientWidth = 635)
德尔福表格高度宽度在不同开发人员机器上的.DFM文件中更改

我想知道为什么(宽度和高度)在形式上改变.dfm文件

我想看在运行时的
(ClientHeight和高度)和(ClientWidth和宽度)

所以如果(宽度= 651)和(ClientWidth = 635)之间的差的计算+原因的击穿
我怎么可以在运行时检查窗口边框宽度或任何我需要锻炼这些值之间的差异?

+0

什么是你的问题,节省? –

+0

我想查看宽度和客户端宽度之间差异的实际值。例如边框尺寸等 – Dangas56

+0

这就是全部?你不是已经在做这个数学吗? 'WidthDiff:= Width - ClientWidth; HeightDiff:= Height - ClientHeight;'或者你还在计算窗口标题区域的非客户端高度? –

回答

1

的.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 Machine 1 机2 Machine 2

+0

这就是答案? –

+0

我已经编辑了答案,现在它更有意义吗?我可以删除这个问题,如果它不会对任何人有用,只是认为它可以帮助遇到同一问题的其他人 – Dangas56