windows – 在Delphi表单上递归更新字体
发布时间:2020-12-14 02:08:26 所属栏目:Windows 来源:网络整理
导读:我正在尝试迭代窗体上的所有控件并启用ClearType字体平滑.像这样的东西: procedure TForm4.UpdateControls(AParent: TWinControl);var I: Integer; ACtrl: TControl; tagLOGFONT: TLogFont;begin for I := 0 to AParent.ControlCount-1 do begin ACtrl:= AP
我正在尝试迭代窗体上的所有控件并启用ClearType字体平滑.像这样的东西:
procedure TForm4.UpdateControls(AParent: TWinControl); var I: Integer; ACtrl: TControl; tagLOGFONT: TLogFont; begin for I := 0 to AParent.ControlCount-1 do begin ACtrl:= AParent.Controls[I]; // if ParentFont=False,update the font here... if ACtrl is TWinControl then UpdateControls(Ctrl as TWinControl); end; end; 现在,是否有一种简单的方法可以检查ACtrl是否具有Font属性,因此我可以将Font.Handle传递给somethink,如: GetObject(ACtrl.Font.Handle,SizeOf(TLogFont),@tagLOGFONT); tagLOGFONT.lfQuality := 5; ACtrl.Font.Handle := CreateFontIndirect(tagLOGFONT); 先感谢您. 解决方法
您使用TypInfo单元,更具体地说是方法IsPublishedProp和GetOrdProp.
在你的情况下,它将是这样的: if IsPublishedProp(ACtrl,'Font') then ModifyFont(TFont(GetOrdProp(ACtrl,'Font'))) 来自我的一个库的片段应该让您走上正确的道路: function ContainsNonemptyControl(controlParent: TWinControl; const requiredControlNamePrefix: string; const ignoreControls: string = ''): boolean; var child : TControl; iControl: integer; ignored : TStringList; obj : TObject; begin Result := true; if ignoreControls = '' then ignored := nil else begin ignored := TStringList.Create; ignored.Text := ignoreControls; end; try for iControl := 0 to controlParent.ControlCount-1 do begin child := controlParent.Controls[iControl]; if (requiredControlNamePrefix = '') or SameText(requiredControlNamePrefix,Copy(child.Name,1,Length(requiredControlNamePrefix))) then if (not assigned(ignored)) or (ignored.IndexOf(child.Name) < 0) then if IsPublishedProp(child,'Text') and (GetStrProp(child,'Text') <> '') then Exit else if IsPublishedProp(child,'Lines') then begin obj := TObject(cardinal(GetOrdProp(child,'Lines'))); if (obj is TStrings) and (Unwrap(TStrings(obj).Text,child) <> '') then Exit; end; end; //for iControl finally FreeAndNil(ignored); end; Result := false; end; { ContainsNonemptyControl } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在Windows 7上安装和配置LDAP(AD LDS)
- win2008 R2 WEB 服务器安全设置指南之组策略与用户设置
- Atitit webdav 的问题 -------------大文件传输问题 在某些
- windows-phone-7 – WP7更改应用程序名称
- WIN2000?SERVER安全配置服务器手册?(2)
- 在Windows上使用FFMPEG从图像流式传输视频
- windows – Delphi 7可以通过OLE Variant传递Int64值吗?
- SMBv2和Windows 7
- Windows 8 ARM,A.K.A. “Windows RT”有Winapi(win32)可供第
- windows-7 – 如何查看端口是否打开?