T
tinyliu2005
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls;<br><br>type<br><br> tpnl = class( TPanel )<br> private<br> procedure WMNCHITTEST(var Message :TWMNCHITTEST); message WM_NCHITTEST;<br><br><br> end;<br><br> TForm1 = class(TForm)<br> Memo1: TMemo;<br> procedure FormCreate(Sender: TObject);<br> procedure FormDestroy(Sender: TObject);<br> private<br> { Private declarations }<br> pnl:tpnl;<br> procedure WMNCHITTEST(var Message :TWMNCHITTEST); message WM_NCHITTEST;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>{ tpnl }<br><br>procedure tpnl.WMNCHITTEST(var Message: TWMNCHITTEST);<br>var<br> dw:integer;<br>begin<br> dw := message.YPos ;<br> dw := dw shl 16;<br> dw := dw + message.XPos;<br>if not (csDesigning in ComponentState) then<br> SendMessage(application.MainForm.Handle ,WM_NCHITTEST,0,dw);<br> inherited;<br><br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> pnl:=tpnl.Create(self);<br> pnl.Color :=clblue;<br> pnl.Parent :=self;<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> pnl.Free;<br>end;<br><br>procedure TForm1.WMNCHITTEST(var Message: TWMNCHITTEST);<br>begin<br> inherited;<br> message.Result :=htcaption;<br> memo1.Lines.Add(inttostr(memo1.Lines.Count +1)+': x = '+<br> inttostr(message.XPos )+'; y = '+<br> inttostr(message.yPos ) );//鼠标在pnl上移动主窗口可以收到此消息,窗口就是不能移动,不懂!<br>end;<br><br>end.<br>