Message Map in Win32 No-MFC

前端 未结 4 2098
耶瑟儿~
耶瑟儿~ 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条回答
  •  猫巷女王i
    2020-12-29 00:28

    The MFC message map doesn't use a regular WndProc per se. IIRC, it is based on some kind of hook mechanism.

    However, I guess it shouldn't be very hard to adapt the macros to an usual WndProc.

    The 1st approach that comes to mind is to let the macros create an array of Message id/Handler function pairs. Even better: Use a map for improved performance.

    Your WndProc would loop through that array to identify the given WM and execute the corresponding handler.

    You might also want the BEGIN_MESSAGE_MAP macros to mimic a switch statement where each ON_BLAH() line would be a case line inside the switch().

    That should be too hard.

提交回复
热议问题