unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, CommCtrl;
type
TForm1 =
class
(TForm)
ListView1: TListView;
ListView2: TListView;
Label1: TLabel;
Label2: TLabel;
procedure
FormCreate(Sender: TObject);
procedure
FormClose(Sender: TObject;
var
Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end
;
var
Form1: TForm1;
lvhOldProc, lvhNewProc: TFarProc;
hHeader: THandle;
implementation
{
$R
*.dfm}
function
LvHeaderNewWndProc(h: THandle; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
phdl: PHDLayout;
prct: PRect;
pwp: PWindowPos;
begin
Result := CallWindowProc(lvhOldProc, h, uMsg, wParam, lParam);
if
uMsg = HDM_LAYOUT
then
begin
phdl := PHDLayout(lParam);
prct := PRect(phdl
.
Rect);
pwp := PWindowPos(phdl
.
WindowPos);
pwp
.
cy := pwp
.
cy +
10
;
// Header默認(rèn)高是17,修改成17 + 10 = 27;
prct
.
top := pwp
.
cy +
2
;
end
;
end
;
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
hHeader := ListView_GetHeader(ListView1
.
Handle);
lvhOldProc := FARPROC(GetWindowLong(hHeader, GWL_WNDPROC));
SetWindowLong(hHeader, GWL_WNDPROC,
Longint
(@LvHeaderNewWndProc));
end
;
procedure
TForm1
.
FormClose(Sender: TObject;
var
Action: TCloseAction);
begin
SetWindowLong(hHeader, GWL_WNDPROC,
Longint
(lvhOldProc));
end
;
end
.