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)
…
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 fashion:
MSG_WM_SIZE(OnSize)
…
LRESULT OnSize(UINT nType, CSize Extent)
{
However, WTL’s macros only crack messages. WM_NOTIFY notifications are to be handled using MSG_WM_NOTIFY macro and the parameters are to be casted in each hander.
An aiwtlcrack.h header file included into project below defines macros to crack notifications for common controls (commctrl.h defined in header file in Platform SDK). The header defines, for example, macros: MSG_NM_DBLCLK, MSG_LVN_ITEMCHANGED, MSG_TVN_CUSTOMDRAW etc. Some of the notifications are duplicated to be able to use specific of the control class. For example, NM_CUSTOMDRAW notification message for a list view can be handled with both MSG_NM_CUSTOMDRAW and MSG_LVN_CUSTOMDRAW. In the latter case the argument will be casted to NMLVCUSTOMDRAW.
Code excerpt from tiny sample project:
BEGIN_MSG_MAP_EX(CMainDialog)
MSG_WM_INITDIALOG(OnInitDialog)
COMMAND_ID_HANDLER_EX(IDOK, OnCommand)
COMMAND_ID_HANDLER_EX(IDCANCEL, OnCommand)
MSG_LVN_GETDISPINFO(IDC_LISTVIEW, OnGetDispInfo)
MSG_LVN_GETINFOTIP(IDC_LISTVIEW, OnGetInfoTip)
MSG_LVN_DBLCLK(IDC_LISTVIEW, OnDblClk)
END_MSG_MAP()
…
LRESULT OnGetDispInfo(NMLVDISPINFO* pHeader)
{
…
}
LRESULT OnGetInfoTip(NMLVGETINFOTIP* pHeader)
{
…
}
LRESULT OnDblClk(NMITEMACTIVATE*)
{
…
}
Visual C++.NET 2003 source code can be downloaded here, compiled binary – here.