不用自绘(owner draw)就改变TListView header的字体
来源:互联网 发布:程序员考试报名网站 编辑:程序博客网 时间:2024/04/30 19:24
To change a font for TListView header
Today I want to show how to use the API calls and change a font for ListView header without any extended programming and custom drawing.
For example, you have the ListView1 instance and want to set a bold font for header.
This task must be solved so:
- to retrieve a handle of header for list view
- to get a font object by header handle
- to define our font object with any custom attributes
- to set our new font for header
The code below will do it:
const LVM_GETHEADER = LVM_FIRST + 31;var LF: TLogFont; hHeader, hCurrFont, hOldFont, hHeaderFont: THandle;begin {to get the windows handle for header} hHeader := SendMessage(ListView1.Handle, LVM_GETHEADER, 0, 0); {to get the handle for header font} hCurrFont := SendMessage(hHeader, WM_GETFONT, 0, 0); {to get the LOGFONT with font details} if GetObject(hCurrFont, SizeOf(LF), Addr(LF)) > 0 then begin {set our custom attributes. I set a bold and underlined font style} LF.lfWeight := FW_BOLD; LF.lfUnderline := 1; {create a new font for the header control to use. This font must NOT be deleted until it is no longer required by the control, typically when the application will be closed or when a new font will be applied to header} hHeaderFont := CreateFontIndirect(LF); {to select the new font} hOldFont := SelectObject(hHeader, hHeaderFont); {to notify the listview header about changes} SendMessage(hHeader, WM_SETFONT, hHeaderFont, 1); end;end;
Note that somewhere in OnFormClose event you must also to release a memory for hHeaderFont variable:
if hHeaderFont > 0 then DeleteObject(hHeaderFont)
- 不用自绘(owner draw)就改变TListView header的字体
- TListView的ListItem完全自绘
- TListView的ListItem完全自绘
- Custom draw 和 Owner draw 的区别
- Combobox的owner draw问题
- owner draw
- 如果在按钮风格中没有勾上owner draw(自绘)风格是,怎样通过代码,设置它的自绘风格
- TListView的自画摸索
- OWNER DRAW / CUSTUM DRAW
- TListView控件的标题栏header高度
- CListCtrl的Owner Draw Fixed属性
- MFC CComboBox 的Owner Draw属性
- 让人迷惑的Custom Draw与Owner draw
- 关于ListCtrol的owner-draw和custom-draw
- 让人迷惑的Custom Draw与Owner draw
- 让人迷惑的Custom Draw与Owner draw
- Custom draw vs Owner draw
- 怎么改变Opera的自带雅黑字体?
- 个人空间地址
- 自动自发的工作
- www.guitar520.cn 关注摇滚音乐
- 马云的江湖 史玉柱的兵法
- CSS进阶1---分类及其创建方法
- 不用自绘(owner draw)就改变TListView header的字体
- 《正在爆发的互联网革命》——Are u ready?
- 通过HSODBC访问mysql的实现步骤
- 启动"Start SoftICE"提示的错误Errror code 31的解决办法
- 如何提高网站流量
- 使TListView header变成flat
- 零打碎敲学Android(四)—跳跃的火之意志!
- 解决ssl启动时要httpd输入密码的问题
- 华北计算所其中一道机试题,逆转字符串,但是单词顺序不变