TListView控件的标题栏header高度,该怎么解决
展开全部
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默认高是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.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询