{"id":42193,"date":"2003-10-13T12:39:00","date_gmt":"2003-10-13T12:39:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2003\/10\/13\/why-is-there-no-wm_mouseenter-message\/"},"modified":"2003-10-13T12:39:00","modified_gmt":"2003-10-13T12:39:00","slug":"why-is-there-no-wm_mouseenter-message","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20031013-00\/?p=42193","title":{"rendered":"Why is there no WM_MOUSEENTER message?"},"content":{"rendered":"<p>\n        There is a <code>WM_MOUSELEAVE<\/code> message. Why isn&#8217;t there a <code>WM_MOUSEENTER<\/code> message?\n    <\/p>\n<p>\n        Because you can easily figure that out for yourself.\n    <\/p>\n<p>\n        When you receive a <code>WM_MOUSELEAVE<\/code> message, set a flag that says, &#8220;The\n        mouse is outside the window.&#8221; When you receive a <code>WM_MOUSEMOVE<\/code> message\n        and the flag is set, then the mouse has entered the window. (And clear the flag while\n        you&#8217;re there.)\n    <\/p>\n<p>\n        Let&#8217;s illustrate this with our sample program, just to make sure you get the idea:\n    <\/p>\n<pre>BOOL g_fMouseInClient;\nvoid OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)\n{\n    if (!g_fMouseInClient) {\n        g_fMouseInClient = TRUE;\n        MessageBeep(0);\n        TRACKMOUSEEVENT tme = { sizeof(tme) };\n        tme.dwFlags = TME_LEAVE;\n        tme.hwndTrack = hwnd;\n        TrackMouseEvent(&amp;tme);\n    }\n}\n    case WM_MOUSELEAVE: g_fMouseInClient = FALSE; return 0;\n    HANDLE_MSG(hwnd, WM_MOUSEMOVE, OnMouseMove);\n<\/pre>\n<p>\n        This program beeps whenever the mouse enters the client area.\n    <\/p>\n<p>    Exercise: If the program starts with the mouse already in the client area without\n    moving, why do you get a beep?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a WM_MOUSELEAVE message. Why isn&#8217;t there a WM_MOUSEENTER message? Because you can easily figure that out for yourself. When you receive a WM_MOUSELEAVE message, set a flag that says, &#8220;The mouse is outside the window.&#8221; When you receive a WM_MOUSEMOVE message and the flag is set, then the mouse has entered the window. [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-42193","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>There is a WM_MOUSELEAVE message. Why isn&#8217;t there a WM_MOUSEENTER message? Because you can easily figure that out for yourself. When you receive a WM_MOUSELEAVE message, set a flag that says, &#8220;The mouse is outside the window.&#8221; When you receive a WM_MOUSEMOVE message and the flag is set, then the mouse has entered the window. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/42193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=42193"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/42193\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=42193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=42193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=42193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}