高手来讲课拿分:移动无标题窗体代码

sdjnjdxc 2004-10-26 08:50:47
Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
Begin
Inherited;
If M.Result = htclient Then
Begin
M.Result := HTCAPTION;
End;
end;
//这样能实现移动无标题窗体
Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
Begin
If M.Result = htclient Then
Begin
M.Result := HTCAPTION;
end;
Inherited; //这样不能实现移动无标题窗体,为什么?
End;

这两种方式,对消息的处理有何不同?

...全文
94 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdjnjdxc 2004-10-26
  • 打赏
  • 举报
回复
thanks
ksaiy 2004-10-26
  • 打赏
  • 举报
回复
Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
Begin
If M.Result = htclient Then
Begin
M.Result := HTCAPTION;
End;
Inherited;
End;

inherited意思是继承原有的消息处理函数.
你把inherited放到判断后面.开始判断的时候没有得到htClient消息.
hottey 2004-10-26
  • 打赏
  • 举报
回复
^_^
jinjazz 2004-10-26
  • 打赏
  • 举报
回复
One of the mouse hit-test enumerated values listed below is the Return Value of OnNcHitTest function.

Mouse Enumerated Values
HTBORDER In the border of a window that does not have a sizing border.
HTBOTTOM In the lower horizontal border of the window.
HTBOTTOMLEFT In the lower-left corner of the window border.
HTBOTTOMRIGHT In the lower-right corner of the window border.
HTCAPTION In a title-bar area.
HTCLIENT In a client area.
HTERROR On the screen background or on a dividing line between windows (same as HTNOWHERE except that the DefWndProc Windows function produces a system beep to indicate an error).
HTGROWBOX In a size box.
HTHSCROLL In the horizontal scroll bar.
HTLEFT In the left border of the window.
HTMAXBUTTON In a Maximize button.
HTMENU In a menu area.
HTMINBUTTON In a Minimize button.
HTNOWHERE On the screen background or on a dividing line between windows.
HTREDUCE In a Minimize button.
HTRIGHT In the right border of the window.
HTSIZE In a size box (same as HTGROWBOX).
HTSYSMENU In a Control menu or in a Close button in a child window.
HTTOP In the upper horizontal border of the window.
HTTOPLEFT In the upper-left corner of the window border.
HTTOPRIGHT In the upper-right corner of the window border.
HTTRANSPARENT In a window currently covered by another window.
HTVSCROLL In the vertical scroll bar.
HTZOOM In a Maximize button.
jinjazz 2004-10-26
  • 打赏
  • 举报
回复
hittest是什么东东?
-----------------------------


The framework calls this member function for the CWnd object that contains the cursor (or the CWnd object that used the SetCapture member function to capture the mouse input) every time the mouse is moved.
sdjnjdxc 2004-10-26
  • 打赏
  • 举报
回复
重新计算HitTest
====================
hittest是什么东东?
beyondtkl 2004-10-26
  • 打赏
  • 举报
回复
呵呵 刚找到的 也是转贴.........

/**************************

在窗体的OnMouseDown事件中加入下面几行代码即可

If Button = mbleft Then
begin
ReleaseCapture;
SendMessage(form1.Handle, WM_NCLBUTTONDOWN, HTCAPTION,0);
end;

若窗体的表面被别的控件履盖掉,则需要把上面的代码加入履盖的控件里面。

版权归金晨所有,请不要转载!

**************************/
alphax 2004-10-26
  • 打赏
  • 举报
回复
inherited放在后面的话,就会重新计算HitTest,结果就覆盖了你的HTCAPTION了

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧