C++ MSG_MAP marcro -> Mixin
BLS
nanali at nospam-wanadoo.fr
Wed Sep 19 12:24:49 PDT 2007
BLS schrieb:
> Hi,
> MFC and wxWidgets are supporting MESSAGEMAPS macros. I would like to
> port them to D.
>
> class CMsg
> {
> public:
>
> virtual BOOL NewMsgProc(HWND hWnd, UINT uID, WPARAM wParam, LPARAM
> lParam,LRESULT lResult)
> {
> return FALSE;
> }
> };
>
> Okay, here iy goes ....
> #define BEGIN_MSG_MAP() \
> public: \
> virtual BOOL NewMsgProc(HWND hWnd, UINT uID, WPARAM wParam, LPARAM
> lParam,LRESULT& lResult) \
> { \
>
> #define ON_MESSAGE(Msg, vfunc) \
> if(uID == Msg) \
> { \
> vfunc(uID, wParam, lParam); \
> lResult = 0; \
> return TRUE; \
> }
>
> #define ON_MESSAGE_RANGE(MsgF, MsgL, vfunc) \
> if(uID >= MsgF && uID <= MsgL) \
> { \
> lResult=vfunc(uID, wParam, lParam); \
> return TRUE; \
> }
>
> #define ON_COMMAND_CONTROL(iControl, iEvent, vfunc) \
> if(uID == WM_COMMAND && iControl == LOWORD(wParam) && iEvent ==
> HIWORD(wParam)) \
> { \
> vfunc(HIWORD(wParam), LOWORD(wParam), (HWND)lParam); \
> lResult = 0; \
> return TRUE; \
> }
>
> and so on....
>
> Is it possible to replace this C++ Macros with D2 Mixins and compile
> time manipulation of strings ?
> How ?
> Thanks, Bjoern
And I really wonder myself how to (probabely) replace this stuff using
Tango's Signal Slot implementation.... but I guess I miss something;
More information about the Digitalmars-d-learn
mailing list