求教 wm_hittest消息用法 (既OnNCHitTest(CPoint)详解)

黄花寒 2009-10-08 12:57:05
如题,各位仙侠,高手,在下不胜感激。
...全文
706 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang3125p 2012-01-12
  • 打赏
  • 举报
回复
我想问一下WM_HITTEST消息是如何产生的,不是根据像素点而产生的
因为有的时候会隔两条此消息之间会隔好多个像素点/
an_bachelor 2009-10-08
  • 打赏
  • 举报
回复
无所谓用发不用法吧 就是鼠标在移动/按下鼠标的时候 会产生这个消息 如果有窗口拥有鼠标捕获 那消息就给该窗口 否则发给鼠标光标下面的窗口
返回值就说明鼠标指针究竟在一个什么地方,如果这消息让DefWindowProc处理 他有一些现成的返回值 比如HTCLOSE说明在Close按钮上 etc 具体的参数可见msdn:



Platform SDK: Windows User Interface
WM_NCHITTEST
The WM_NCHITTEST message is sent to a window when the cursor moves, or when a mouse button is pressed or released. If the mouse is not captured, the message is sent to the window beneath the cursor. Otherwise, the message is sent to the window that has captured the mouse.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_NCHITTEST
WPARAM wParam, // not used
LPARAM lParam // horizontal and vertical position
);
Parameters
wParam
This parameter is not used.
lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the screen.
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the screen.

Return Values
The return value of the DefWindowProc function is one of the following values, indicating the position of the cursor hot spot.

Value Location of hot spot
HTBORDER In the border of a window that does not have a sizing border.
HTBOTTOM In the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically).
HTBOTTOMLEFT In the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTBOTTOMRIGHT In the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTCAPTION In a title bar.
HTCLIENT In a client area.
HTCLOSE In a Close button.
HTERROR On the screen background or on a dividing line between windows (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error).
HTGROWBOX In a size box (same as HTSIZE).
HTHELP In a Help button.
HTHSCROLL In a horizontal scroll bar.
HTLEFT In the left border of a resizable window (the user can click the mouse to resize the window horizontally).
HTMENU In a menu.
HTMAXBUTTON In a Maximize button.
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 a resizable window (the user can click the mouse to resize the window horizontally).
HTSIZE In a size box (same as HTGROWBOX).
HTSYSMENU In a window menu or in a Close button in a child window.
HTTOP In the upper-horizontal border of a window.
HTTOPLEFT In the upper-left corner of a window border.
HTTOPRIGHT In the upper-right corner of a window border.
HTTRANSPARENT In a window currently covered by another window in the same thread (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT).
HTVSCROLL In the vertical scroll bar.
HTZOOM In a Maximize button.


Remarks
Use the following code to obtain the horizontal and vertical position:

xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
You can also use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.

Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.

See Also
Mouse Input Overview, Mouse Input Messages, DefWindowProc, GET_X_LPARAM, GET_Y_LPARAM, MAKEPOINTS, POINTS

Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)



Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.
See Also
Mouse Input Overview, Mouse Input Messages, DefWindowProc, GET_X_LPARAM, GET_Y_LPARAM, MAKEPOINTS, POINTS

quaserent 2009-10-08
  • 打赏
  • 举报
回复
额 等待高人

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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