Menu

New macros in <atlcrack.h>

Sergei
2019-07-03
2020-03-20
  • Sergei

    Sergei - 2019-07-03

    Maybe add the listed macros to the file atlcrack.h?

    // LRESULT OnNotifyCodeRangeHandlerEx(LPNMHDR lpNmh)
    #define NOTIFY_CODE_RANGE_HANDLER_EX(cdFirst, cdLast, func) \
        if (uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->code >= cdFirst && ((LPNMHDR)lParam)->code <= cdLast) \
        { \
            SetMsgHandled(TRUE); \
            lResult = func((LPNMHDR)lParam); \
            if (IsMsgHandled()) \
                return TRUE; \
        }
    
    // void OnNcMouseLeave(void)
    #define MSG_WM_NCMOUSELEAVE(func) \
        if (uMsg == WM_NCMOUSELEAVE) \
        { \
            this->SetMsgHandled(TRUE); \
            func(); \
            lResult = 0; \
            if(this->IsMsgHandled()) \
                return TRUE; \
        }
    
    // void OnNcMouseHover(UINT uiHitTest, CPoint ptPos)
    #define MSG_WM_NCMOUSEHOVER(func) \
        if (uMsg == WM_NCMOUSEHOVER) \
        { \
            this->SetMsgHandled(TRUE); \
            func((UINT)wParam, ::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
            lResult = 0; \
            if(this->IsMsgHandled()) \
                return TRUE; \
        }
    

    And change the macros BEGIN_MSG_MAP_EX (сhanges are marked by **) to:

    #define BEGIN_MSG_MAP_EX(theClass) \
    public: \
        BOOL m_bMsgHandled; \
        /* "handled" management for cracked handlers */ \
        **const BOOL&** IsMsgHandled() const \
        { \
            return m_bMsgHandled; \
        } \
        void SetMsgHandled(**const** BOOL bHandled) \
        { \
            m_bMsgHandled = bHandled; \
        } \
        BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
        { \
            **const BOOL** bOldMsgHandled = m_bMsgHandled; \
            **const BOOL** bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
            m_bMsgHandled = bOldMsgHandled; \
            return bRet; \
        } \
        **const** BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \
        { \
            BOOL bHandled = TRUE; \
            (hWnd); \
            (uMsg); \
            (wParam); \
            (lParam); \
            (lResult); \
            (bHandled); \
            switch(dwMsgMapID) \
            { \
            case 0:
    
     

    Last edit: Sergei 2019-07-05
  • Nenad Stefanovic

    Thanks for your proposals.

    I added MSG_WM_NCMOUSEHOVER() and MSG_WM_NCMOUSELEAVE() to atlcrack.h

    NOTIFY_CODE_RANGE_HANDLER_EX() is not suitable - we never have 'code range' macros. Codes are not always sequential, and neither ATL nor WTL have macros like that.

    Proposed changes for BEGIN_MSG_MAP_EX () are correct, but not needed. We there have code from CWindowImpl, and we use the same code that ATL has there.

     

Log in to post a comment.