unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls,CommCtrl; type PHD_NOTIFY=^HD_NOTIFY; TForm1 = class(TForm) ListView1: TListView; Button1: TButton; procedure FormDestroy(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } oldProc: TWndMethod; procedure NewProc(var Message: TMessage); public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.NewProc(var Message: TMessage); var hn:PHD_NOTIFY; begin if message.Msg=WM_NOTIFY then begin hn:=PHD_NOTIFY(Message.LParam); if(hn^.Hdr.code=HDN_BEGINTRACKA)or(hn^.hdr.code=HDN_BEGINTRACKW) then begin // Message.Result := 1; 加入這一行就使的列頭不能改變寬度 // 如果要在拖動完成後作處理,可以判斷hn->hdr.code是否 // 等於HDN_ENDTRACKA或HDN_ENDTRACKW,然後作處理。 ShowMessage('hehe'); end else ListView1.Dispatch(Message); end; end; procedure TForm1.FormDestroy(Sender: TObject); begin ListView1.WindowProc:=OldProc; end; procedure TForm1.Button1Click(Sender: TObject); begin OldProc:= ListView1.WindowProc; ListView1.WindowProc:= NewProc; end; end.