使TListView header变成flat

How to set a flat style for TListView header

 

In this tip I want to show how to change a style for header in
TListView. For example, you may specify a flat header.

You may do it so:
1. to get the header handle for the listview
2. to read the current style attributes for the header
3. to modify a style
4. to apply the new style
5. to invalidate the listview

In the next code I show how to apply a flat style:

const
  LVM_GETHEADER = LVM_FIRST + 31;
var
  hHeader: THandle;
  style: dWord;
begin
  {to get the header handle for the listview}
  hHeader := SendMessage(ListView1.Handle, LVM_GETHEADER, 0, 0);

  {to get the current style attributes for the header}
  style := GetWindowLong(hHeader, GWL_STYLE);

  {to toggle the HDS_BUTTONS style}
  style := style xor HDS_BUTTONS;

  {to apply the new style}
  SetWindowLong(hHeader, GWL_STYLE, style);

  {to invalidate the listview}
  SetWindowPos(ListView1.Handle, Form1.Handle, 0, 0, 0, 0, SWP_NOZORDER
or SWP_NOSIZE or SWP_NOMOVE or SWP_DRAWFRAME)
end;

Note if you run a code in Windows XP with enabled XP theming, you'll not
see any difference. But in all other cases you'll see a flat header for
ListView

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值