Message Map in Win32 No-MFC

前端 未结 4 2097
耶瑟儿~
耶瑟儿~ 2020-12-29 00:08

How could I create similar structure to handle Win32 Messages like it is in MFC?

In MFC;

BEGIN_MESSAGE_MAP(CSkinCtrlTestDlg, CDialog)
    //{{AFX_MSG         


        
4条回答
  •  星月不相逢
    2020-12-29 00:42

    It's difficult to do this with something like an std::map. In particular, that requires that every item in the map has the same type, but different messages have handlers that take different numbers of parameters, so pointers to them aren't the same type.

    You might want to take a look at the message cracker macros (especially HANDLE_MSG) in windowsx.h though. Though this really just generates case's for a switch statement, it still lets you write code that looks something like an MFC message map.

提交回复
热议问题