{"id":165,"date":"2007-01-11T18:37:31","date_gmt":"2007-01-11T16:37:31","guid":{"rendered":"https:\/\/alax.info\/blog\/165"},"modified":"2007-01-11T18:41:57","modified_gmt":"2007-01-11T16:41:57","slug":"wtl-style-notification-message-cracking-macros-for-common-control-notifications","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/165","title":{"rendered":"WTL style notification message cracking macros for common control notifications"},"content":{"rendered":"<p><a href=\"http:\/\/wtl.sf.net\">Windows Template Library<\/a> contains <em>atlcrack.h<\/em> header file with macros to reinterpret window message parameters: split if required and cast to proper type. For instance, instead of:<\/p>\n<blockquote><p><em> MESSAGE_HANDLER_EX(WM_SIZE, OnSize)<br \/>\n&#8230;<br \/>\nLRESULT OnSize(UINT, WPARAM wParam, LPARAM lParam)<br \/>\n{<br \/>\nUINT nType = (UINT) wParam;<br \/>\nCSize Extent(LOWORD(lParam), HIWORD(lParam));<\/em><\/p><\/blockquote>\n<p>it allows to make things simpler and in a more reliable fashion:<\/p>\n<blockquote><p><em>MSG_WM_SIZE(OnSize)<br \/>\n&#8230;<br \/>\nLRESULT OnSize(UINT nType, CSize Extent)<br \/>\n{<\/em><\/p><\/blockquote>\n<p>However, WTL&#8217;s macros only crack messages. <em><a href=\"http:\/\/msdn2.microsoft.com\/en-us\/ms672614.aspx\">WM_NOTIFY<\/a><\/em> notifications are to be handled using <em>MSG_WM_NOTIFY<\/em> macro and the parameters are to be casted in each hander.<\/p>\n<p>An <em>aiwtlcrack.h<\/em> header file included into project below defines macros to crack notifications for common controls (<em>commctrl.h<\/em> defined in header file in Platform SDK). The header defines, for example, macros: <strong><em>MSG_NM_DBLCLK<\/em><\/strong>, <strong><em>MSG_LVN_ITEMCHANGED<\/em><\/strong>, <strong><em>MSG_TVN_CUSTOMDRAW<\/em><\/strong> etc. Some of the notifications are duplicated to be able to use specific of the control class. For example, <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/ms672574.aspx\"><em>NM_CUSTOMDRAW<\/em><\/a> notification message for a list view can be handled with both <em>MSG_NM_CUSTOMDRAW<\/em> and <em>MSG_LVN_CUSTOMDRAW<\/em>. In the latter case the argument will be casted to <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/ms670578.aspx\"><em>NMLVCUSTOMDRAW<\/em><\/a>.<\/p>\n<p><!--more--><\/p>\n<p>Code excerpt from tiny sample project:<\/p>\n<blockquote><p>BEGIN_MSG_MAP_EX(CMainDialog)<br \/>\nMSG_WM_INITDIALOG(OnInitDialog)<br \/>\nCOMMAND_ID_HANDLER_EX(IDOK, OnCommand)<br \/>\nCOMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)<br \/>\n<strong>    MSG_LVN_GETDISPINFO(IDC_LISTVIEW, OnGetDispInfo)<br \/>\nMSG_LVN_GETINFOTIP(IDC_LISTVIEW, OnGetInfoTip)<br \/>\nMSG_LVN_DBLCLK(IDC_LISTVIEW, OnDblClk)<br \/>\n<\/strong>END_MSG_MAP()<br \/>\n&#8230;<br \/>\nLRESULT OnGetDispInfo(NMLVDISPINFO* pHeader)<br \/>\n{<br \/>\n&#8230;<br \/>\n}<br \/>\nLRESULT OnGetInfoTip(NMLVGETINFOTIP* pHeader)<br \/>\n{<br \/>\n&#8230;<br \/>\n}<br \/>\nLRESULT OnDblClk(NMITEMACTIVATE*)<br \/>\n{<br \/>\n&#8230;<br \/>\n}<\/p><\/blockquote>\n<p>Visual C++.NET 2003 source code can be downloaded <a id=\"p113\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2007\/01\/commoncontrolsnotificationcrackmacros.zip\">here<\/a>, compiled binary &#8211; <a id=\"p114\" href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2007\/01\/commoncontrolsnotificationcrackmacrosexe.zip\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Template Library contains atlcrack.h header file with macros to reinterpret window message parameters: split if required and cast to proper type. For instance, instead of: MESSAGE_HANDLER_EX(WM_SIZE, OnSize) &#8230; LRESULT OnSize(UINT, WPARAM wParam, LPARAM lParam) { UINT nType = (UINT) wParam; CSize Extent(LOWORD(lParam), HIWORD(lParam)); it allows to make things simpler and in a more reliable&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/165\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13,20],"tags":[],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-atl","category-source","category-wtl"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}