procedure WMncHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;procedure TForm1.WMncHitTest(var Msg: TWMNCHitTest);
begin
Msg.Result := HTCAPTION;
end;
begin
Msg.Result := HTCAPTION;
end;
TForm1 = class(TForm)
//.........
private
{ Private declarations }
procedure AppMessage(var Msg:TMsg);message WM_LButtonDown;
public
{ Public declarations }
end;procedure TForm1.AppMessage(var Msg:TMsg);
begin
SendMessage(Handle,WM_NCLButtonDown,HTCaption,GetMessagePos);
end;
begin
inherited;//--------最好加个他
if M.Result=htClient then
M.Result := htCaption;
end;
這種方法﹐肯定是不行的﹐可以移動﹐但按鈕卻不起作用了﹐我查了一下幫助﹐好像沒有別的適合的返回值
原因:我只截获Form的消息,并没有截获Form上面控件的消息。
的消息,按钮是可以按,当无法拖动。
To WillianGui: 现在我是双管齐下,Form用WM_NCHITTEST,TWinControl的用MouseDown手工编。
form1的x,y就加上鼠标移动的数值,看这样行不行。
1 .声明一个过程ChangeMessageValue(var msg:TWMNCHitTest); message WM_NCHITTEST;
2 .代码实现:
Procedure TForm1.ChangeMessageValue(var msg:TWMNChitTest);
begin
inherited;
if htClient=msg.Result then
msg.Result:=htCaption;
end;
其中,TWMNChitTest是Messages单元中的一个记录。
感謝大家的回答﹐大家還是先試試再說﹐
一個沒邊框的窗口﹐加一個speedbutton的按鈕﹐作為close﹐拖動﹐且支持點擊按鈕退出這個問題困擾了我四五個月﹐不過﹐昨晚我基本上解決了﹐很簡單﹐只寫一句話﹗﹗﹗