为适应多语言,需要对界面控件大小.位置多动态改变,因此需要根据其Caption计算实际像素大小. 找资料未有易用现成的,遂参数其它方法,写以函数处之,代码如下: uses TypInfo; function GetTextWidth(AControl: TControl): Integer; function GetControlFont: TFont; var PropInfo: PPropInfo; begin Result := nil; PropInfo := GetPropInfo(A
方法一: Var I: Integer; Begin For I := To ComponentCount - Do //获取组件数量 Begin If Components[I] Is TWinControl Then Begin If (Components[I] As TWinControl).Focused Then Begin Self.Caption := (Components[I] As TWinControl).Name; Break; End; End; End; 方法二:
Delphi获取默认打印机名称及端口 在前段时间写的收银系统中由于目前市场上很多电脑主板上已经没有并口,而POS机却又需要并口,所以目前需要用PCI转接卡,这个就导致不同门店使用的端口就有可能不同,这就给我们程序中弹出钱箱的指令带来一定的难度.所以就通过获取Window自带的默认,得出打印机信息. 在Windows文件下有个win.ini,里面自带默认打印机的信息.通过调用API函数Getprofilestring这个函数获取打印机信息. 在界面上拖个button,在其单击事件中写: pro