{"id":9743,"date":"2011-09-02T07:00:00","date_gmt":"2011-09-02T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2011\/09\/02\/whats-the-story-with-the-parameters-to-the-wm_input_device_change-message\/"},"modified":"2011-09-02T07:00:00","modified_gmt":"2011-09-02T07:00:00","slug":"whats-the-story-with-the-parameters-to-the-wm_input_device_change-message","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20110902-00\/?p=9743","title":{"rendered":"What&#039;s the story with the parameters to the WM_INPUT_DEVICE_CHANGE message?"},"content":{"rendered":"<p>\nA customer found these strange macros in <tt>winuser.h<\/tt>:\n<\/p>\n<pre>\n#if (_WIN32_WINNT &gt;= 0x0601)\n#define GET_DEVICE_CHANGE_WPARAM(wParam)  (LOWORD(wParam))\n#elif (_WIN32_WINNT &gt;= 0x0501)\n#define GET_DEVICE_CHANGE_LPARAM(lParam)  (LOWORD(lParam))\n#endif \/* (_WIN32_WINNT &gt;= 0x0601) *\/\n<\/pre>\n<p>\nAccording to the documentation for the\n<code>WM_INPUT_DEVICE_CHANGE<\/code>\nmessage, the <code>wParam<\/code> is the operation code\nand the <code>lParam<\/code> is a handle to the device that changed.\nGiven that definition, the correct macro would be\n<code>GET_DEVICE_CHANGE_WPARAM<\/code>.\nWhat&#8217;s up with the bogus\n<code>GET_DEVICE_CHANGE_LPARAM<\/code> macro?\n<\/p>\n<p>\nThe macro was incorrectly defined in Windows&nbsp;Vista.\nIn the Windows&nbsp;7 version of the Platform&nbsp;SDK,\nthe correct macro was added,\nbut in order to avoid introducing a breaking change to existing code,\nthe old broken macro remains in place in order to retain\nbug-for-bug compatibility with existing code.\n<\/p>\n<p>\nEven though the macro didn&#8217;t work,\nthere is a good possibility\nthat code exists which relied on it anyway.\nFor example,\npeople may have read the documentation, read the macro,\nrealized that the macro was wrong, and worked around the bug\nlike this:\n<\/p>\n<pre>\ncase WM_INPUT_DEVICE_CHANGE:\n return OnInputDeviceChange(GET_DEVICE_CHANGE_LPARAM(wParam),\n                            (HANDLE)lParam);\n<\/pre>\n<p>\nTo avoid breaking this code,\nthe old broken definition remains in the header file.\nBut at least it&#8217;s defined only if you say that you want the\nWindows&nbsp;Vista version of the header file, so at least\npeople won&#8217;t use the bad macro\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2007\/09\/25\/5108967.aspx\">\ngoing forward<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer found these strange macros in winuser.h: #if (_WIN32_WINNT &gt;= 0x0601) #define GET_DEVICE_CHANGE_WPARAM(wParam) (LOWORD(wParam)) #elif (_WIN32_WINNT &gt;= 0x0501) #define GET_DEVICE_CHANGE_LPARAM(lParam) (LOWORD(lParam)) #endif \/* (_WIN32_WINNT &gt;= 0x0601) *\/ According to the documentation for the WM_INPUT_DEVICE_CHANGE message, the wParam is the operation code and the lParam is a handle to the device that changed. Given that [&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":[2],"class_list":["post-9743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>A customer found these strange macros in winuser.h: #if (_WIN32_WINNT &gt;= 0x0601) #define GET_DEVICE_CHANGE_WPARAM(wParam) (LOWORD(wParam)) #elif (_WIN32_WINNT &gt;= 0x0501) #define GET_DEVICE_CHANGE_LPARAM(lParam) (LOWORD(lParam)) #endif \/* (_WIN32_WINNT &gt;= 0x0601) *\/ According to the documentation for the WM_INPUT_DEVICE_CHANGE message, the wParam is the operation code and the lParam is a handle to the device that changed. Given that [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9743","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=9743"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/9743\/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=9743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=9743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=9743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}