How could I create similar structure to handle Win32 Messages like it is in MFC?
In MFC;
BEGIN_MESSAGE_MAP(CSkinCtrlTestDlg, CDialog)
//{{AFX_MSG
You could use something like a std::map< short, MessageFn >. Where short is the window message and MessageFn is the function that handles the message. You can then handle messages as follows:
if ( messageMap.find( uMsg ) != messageMap.end() )
{
messageMap[uMsg]( wParam, lParam );
}
It won't be quite as neat but would be pretty easy to implement, though you'd be defining the message map at runtime rather than at compile time.
Another solution is to read through the MFC macro code and see how microsoft did it ...
Another solution, if you want MFC like behaviour without the overhead, is using ATL. You can also have a look at ATL's macro definitions to see how they did it ....
Edit: You can solve WM_COMMAND or WM_NOTIFY handling by storing a CommandMap and a NotifyMap as well. You then set the WM_COMMAND handler to a function that then does a similar thing and passes the command on through the CommandMap.
Your biggest issue is the fact that you don't get anything in the message that identifies a specific class instance. This isn't a problem if you only need the hWnd but youj may need to store a further global map of HWNDs to class instances ...
This is only 1 solution. You can solve the problem in many different ways. I'm just throwing 1 idea out there for you.