TListView控件的标题栏header高度,该怎么解决
推荐于2016-09-07 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517164
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
一段代码真正实现楼主的需求:
Delphi(Pascal) codeunit 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.
Delphi(Pascal) codeunit 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.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询