Y
yeah
Unregistered / Unconfirmed
GUEST, unregistred user!
各位,如何手动发送WM_NCHITTEST消息?具体情况如下:<br>我做了一个Netants类似的拖放窗口(DropBasket),代码如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> ExtCtrls, Menus;<br><br>type<br> TForm1 = class(TForm)<br> Image1: TImage;<br> PopupMenu1: TPopupMenu;<br> abadsdfasdf1: TMenuItem;<br> procedure FormCreate(Sender: TObject);<br> private<br> procedure WM_NCHITTEST(Var Message:TWMNCHITTEST); Message WM_NCHITTEST;<br> procedure WM_NCLBUTTONDBLCLK(Var Message:TWMNCLBUTTONDBLCLK); Message WM_NCLBUTTONDBLCLK;<br> procedure WM_NCRBUTTONUP(Var Message:TWMNCRBUTTONUP); Message WM_NCRBUTTONUP;<br> { Private declarations }<br> public<br> procedure CreateParams(Var Params:TCreateParams);override;<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>uses main;<br>procedure TForm1.CreateParams(var Params: TCreateParams);<br>begin<br> inherited CreateParams(Params);<br> With Params do<br> begin<br> params.WndParent:=GetDesktopWindow;<br> EXSTYLE:=EXSTYLE or WS_EX_TOOLWINDOW OR WS_EX_TOPMOST;<br> end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and not ws_Caption);<br> Width:=40;<br> Height:=40;<br> Image1.Picture.Icon:=Application.Icon;<br>end;<br><br>procedure TForm1.WM_NCHITTEST(var Message: TWMNCHITTEST);<br>begin<br> Inherited;<br> if Message.Result=HTCLIENT then Message.Result:=HTCAPTION;<br>end;<br><br>procedure TForm1.WM_NCLBUTTONDBLCLK(var Message: TWMNCLBUTTONDBLCLK);<br>begin<br> inherited;<br> ShowMessage('I get DblClick Message!');<br> SetActiveWindow(frmMain.Handle);<br>end;<br><br>procedure TForm1.WM_NCRBUTTONUP(var Message: TWMNCRBUTTONUP);<br>begin<br> inherited;<br> PopupMenu1.Popup(Message.XCursor,Message.YCursor);<br>end;<br><br>end.<br><br>以上代码在win98中正常,可是今天,我在win2000中运行了此程序,<br>发现除了WM_NCHITTEST消息总是被触发(WM_NCRBUTTONUP也正常)外,<br>WM_NCLBUTTONDBLCLK消息却永远不被执行,当我双击窗体时,<br>窗口被最大化!(因为WM_NCHITTEST先被执行,而此时的双击被<br>理解为在标题栏上的双击,所以它总是执行最大化、还原两个动作。)<br>我要问的实际上不只是以上这个问题的解决办法,而且想知道<br>如何手动发送WM_NCHITTEST消息?我不知道如何在SendMessage中如何<br>指定Lparam参数(在WM_NCHITTEST消息中,它是一个TPoint)