From e60a4f00b5e372a854ac089f66b5cdaaac90c1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 27 Dec 2021 19:48:19 +0100 Subject: [PATCH] [ATL] atlwin.h: Formatting, and add a comment in IsParentDialog(). --- sdk/lib/atl/atlwin.h | 236 ++++++++++++++++++++++--------------------- 1 file changed, 120 insertions(+), 116 deletions(-) diff --git a/sdk/lib/atl/atlwin.h b/sdk/lib/atl/atlwin.h index 214c2959789..0c1251e6525 100644 --- a/sdk/lib/atl/atlwin.h +++ b/sdk/lib/atl/atlwin.h @@ -60,7 +60,6 @@ namespace ATL #endif - struct _ATL_WNDCLASSINFOW; typedef _ATL_WNDCLASSINFOW CWndClassInfo; @@ -168,7 +167,7 @@ struct thunkCode m_mov = 0x042444C7; m_this = PtrToUlong(pThis); m_jmp = 0xe9; - m_relproc = DWORD(reinterpret_cast(proc) - (reinterpret_cast(this) + sizeof(thunkCode))); + m_relproc = DWORD(reinterpret_cast(proc) - (reinterpret_cast(this) + sizeof(thunkCode))); FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode)); } }; @@ -229,8 +228,8 @@ class CWndProcThunk public: thunkCode *m_pthunk; _AtlCreateWndData cd; -public: +public: CWndProcThunk() { m_pthunk = (thunkCode*)VirtualAlloc(NULL, sizeof(thunkCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE); @@ -267,6 +266,7 @@ class CWindow public: HWND m_hWnd; static RECT rcDefault; + public: CWindow(HWND hWnd = NULL) { @@ -873,8 +873,8 @@ public: BOOL IsParentDialog() { ATLASSERT(::IsWindow(m_hWnd)); - TCHAR pszType[10]; - if (!RealGetWindowClass(::GetParent(m_hWnd), pszType, sizeof(pszType) / sizeof(pszType[0]))) + TCHAR pszType[10]; // Use sizeof("#32770")+3 so that extra characters can be detected. + if (!RealGetWindowClass(::GetParent(m_hWnd), pszType, _countof(pszType))) return FALSE; return !_tcscmp(pszType, _T("#32770")); } @@ -1345,7 +1345,7 @@ public: static INT_PTR CALLBACK StartDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CDialogImplBaseT *pThis; + CDialogImplBaseT* pThis; DLGPROC newDlgProc; DLGPROC GCCU(pOldProc); @@ -1353,6 +1353,7 @@ public: ATLASSERT(pThis != NULL); if (pThis == NULL) return 0; + pThis->m_thunk.Init((WNDPROC)pThis->GetDialogProc(), pThis); newDlgProc = reinterpret_cast(pThis->m_thunk.GetWNDPROC()); pOldProc = reinterpret_cast(::SetWindowLongPtr(hWnd, DWLP_DLGPROC, reinterpret_cast(newDlgProc))); @@ -1363,7 +1364,7 @@ public: static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CDialogImplBaseT *pThis = reinterpret_cast*>(hWnd); + CDialogImplBaseT* pThis = reinterpret_cast*>(hWnd); _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); LRESULT lResult = 0; const _ATL_MSG *previousMessage; @@ -1410,7 +1411,7 @@ public: template -class CDialogImpl : public CDialogImplBaseT< TBase > +class CDialogImpl : public CDialogImplBaseT { public: // + Hacks for gcc @@ -1488,7 +1489,7 @@ public: ATLASSERT(m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); - CWindowImplBaseT *pThis; + CWindowImplBaseT* pThis; pThis = reinterpret_cast*>(this); BOOL result = m_thunk.Init(GetWindowProc(), this); @@ -1545,22 +1546,22 @@ public: LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { - CWindowImplBaseT *pThis; - - pThis = reinterpret_cast *>(this); + CWindowImplBaseT* pThis; + pThis = reinterpret_cast*>(this); return ::CallWindowProc(m_pfnSuperWindowProc, pThis->m_hWnd, uMsg, wParam, lParam); } static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CWindowImplBaseT *pThis; + CWindowImplBaseT* pThis; WNDPROC newWindowProc; WNDPROC GCCU(pOldProc); - pThis = reinterpret_cast *>(_AtlWinModule.ExtractCreateWndData()); + pThis = reinterpret_cast*>(_AtlWinModule.ExtractCreateWndData()); ATLASSERT(pThis != NULL); if (pThis == NULL) return 0; + pThis->m_thunk.Init(pThis->GetWindowProc(), pThis); newWindowProc = pThis->m_thunk.GetWNDPROC(); pOldProc = reinterpret_cast(::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast(newWindowProc))); @@ -1571,7 +1572,7 @@ public: static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CWindowImplBaseT *pThis = reinterpret_cast *>(hWnd); + CWindowImplBaseT* pThis = reinterpret_cast*>(hWnd); _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); LRESULT lResult; const _ATL_MSG *previousMessage; @@ -1605,7 +1606,9 @@ public: pThis->m_dwState |= WINSTATE_DESTROYED; } else + { lResult = pThis->DefWindowProc(uMsg, wParam, lParam); + } } ATLASSERT(pThis->m_pCurrentMsg == &msg); pThis->m_pCurrentMsg = previousMessage; @@ -1619,9 +1622,9 @@ public: } HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, - _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam) + _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam) { - HWND hWnd; + HWND hWnd; ATLASSERT(m_hWnd == NULL); ATLASSERT(atom != 0); @@ -1638,6 +1641,7 @@ public: MenuOrID.m_hMenu = (HMENU)(UINT_PTR)this; if (rect.m_lpRect == NULL) rect.m_lpRect = &TBase::rcDefault; + hWnd = ::CreateWindowEx(dwExStyle, MAKEINTATOM(atom), szWindowName, dwStyle, rect.m_lpRect->left, rect.m_lpRect->top, rect.m_lpRect->right - rect.m_lpRect->left, rect.m_lpRect->bottom - rect.m_lpRect->top, hWndParent, MenuOrID.m_hMenu, _AtlBaseModule.GetModuleInstance(), lpCreateParam); @@ -1657,16 +1661,15 @@ public: using CWindowImplRoot::m_hWnd; // - Hacks for gcc - static LPCTSTR GetWndCaption() { return NULL; } HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, - DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) + DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL) { - CWindowImplBaseT *pThis; + CWindowImplBaseT* pThis; ATOM atom; ATLASSERT(m_hWnd == NULL); @@ -1700,6 +1703,7 @@ public: CMessageMap *m_pObject; DWORD m_dwMsgMapID; const _ATL_MSG *m_pCurrentMsg; + public: CContainedWindowT(CMessageMap *pObject, DWORD dwMsgMapID = 0) { @@ -1729,8 +1733,8 @@ public: ATLASSERT(m_hWnd == NULL); ATLASSERT(::IsWindow(hWnd)); - CContainedWindowT *pThis; - pThis = reinterpret_cast *>(this); + CContainedWindowT* pThis; + pThis = reinterpret_cast*>(this); BOOL result = m_thunk.Init(WindowProc, pThis); if (result == FALSE) @@ -1770,11 +1774,11 @@ public: static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CContainedWindowT *pThis; + CContainedWindowT* pThis; WNDPROC newWindowProc; WNDPROC GCCU(pOldProc); - pThis = reinterpret_cast *>(_AtlWinModule.ExtractCreateWndData()); + pThis = reinterpret_cast*>(_AtlWinModule.ExtractCreateWndData()); ATLASSERT(pThis != NULL); if (pThis == NULL) return 0; @@ -1788,7 +1792,7 @@ public: static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - CContainedWindowT *pThis = reinterpret_cast *>(hWnd); + CContainedWindowT* pThis = reinterpret_cast*>(hWnd); _ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam); LRESULT lResult; const _ATL_MSG *previousMessage; @@ -1826,122 +1830,122 @@ public: }; typedef CContainedWindowT CContainedWindow; -#define BEGIN_MSG_MAP(theClass) \ -public: \ - BOOL ProcessWindowMessage(HWND GCCU(hWnd), UINT GCCU(uMsg), WPARAM GCCU(wParam), LPARAM GCCU(lParam), LRESULT &GCCU(lResult), DWORD dwMsgMapID = 0) \ - { \ - BOOL GCCU(bHandled) = TRUE; \ - Unused(hWnd); \ - Unused(uMsg); \ - Unused(wParam); \ - Unused(lParam); \ - Unused(lResult); \ - Unused(bHandled); \ - switch(dwMsgMapID) \ - { \ +#define BEGIN_MSG_MAP(theClass) \ +public: \ + BOOL ProcessWindowMessage(HWND GCCU(hWnd), UINT GCCU(uMsg), WPARAM GCCU(wParam), LPARAM GCCU(lParam), LRESULT &GCCU(lResult), DWORD dwMsgMapID = 0) \ + { \ + BOOL GCCU(bHandled) = TRUE; \ + Unused(hWnd); \ + Unused(uMsg); \ + Unused(wParam); \ + Unused(lParam); \ + Unused(lResult); \ + Unused(bHandled); \ + switch(dwMsgMapID) \ + { \ case 0: -#define ALT_MSG_MAP(map) \ - break; \ +#define ALT_MSG_MAP(map) \ + break; \ case map: -#define END_MSG_MAP() \ - break; \ - default: \ - ATLASSERT(FALSE); \ - break; \ - } \ - return FALSE; \ +#define END_MSG_MAP() \ + break; \ + default: \ + ATLASSERT(FALSE); \ + break; \ + } \ + return FALSE; \ } -#define MESSAGE_HANDLER(msg, func) \ - if (uMsg == msg) \ - { \ - bHandled = TRUE; \ - lResult = func(uMsg, wParam, lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define MESSAGE_HANDLER(msg, func) \ + if (uMsg == msg) \ + { \ + bHandled = TRUE; \ + lResult = func(uMsg, wParam, lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define MESSAGE_RANGE_HANDLER(msgFirst, msgLast, func) \ - if (uMsg >= msgFirst && uMsg <= msgLast) \ - { \ - bHandled = TRUE; \ - lResult = func(uMsg, wParam, lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define MESSAGE_RANGE_HANDLER(msgFirst, msgLast, func) \ + if (uMsg >= msgFirst && uMsg <= msgLast) \ + { \ + bHandled = TRUE; \ + lResult = func(uMsg, wParam, lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define COMMAND_HANDLER(id, code, func) \ - if (uMsg == WM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define COMMAND_HANDLER(id, code, func) \ + if (uMsg == WM_COMMAND && id == LOWORD(wParam) && code == HIWORD(wParam)) \ + { \ + bHandled = TRUE; \ + lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define COMMAND_ID_HANDLER(id, func) \ - if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define COMMAND_ID_HANDLER(id, func) \ + if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \ + { \ + bHandled = TRUE; \ + lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define COMMAND_CODE_HANDLER(code, func) \ - if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define COMMAND_CODE_HANDLER(code, func) \ + if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \ + { \ + bHandled = TRUE; \ + lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define COMMAND_RANGE_HANDLER(idFirst, idLast, func) \ - if (uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ - { \ - bHandled = TRUE; \ - lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define COMMAND_RANGE_HANDLER(idFirst, idLast, func) \ + if (uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \ + { \ + bHandled = TRUE; \ + lResult = func(HIWORD(wParam), LOWORD(wParam), (HWND)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define NOTIFY_CODE_HANDLER(cd, func) \ - if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define NOTIFY_CODE_HANDLER(cd, func) \ + if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \ + { \ + bHandled = TRUE; \ + lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define NOTIFY_HANDLER(id, cd, func) \ - if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ - { \ - bHandled = TRUE; \ - lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ - if (bHandled) \ - return TRUE; \ +#define NOTIFY_HANDLER(id, cd, func) \ + if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \ + { \ + bHandled = TRUE; \ + lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \ + if (bHandled) \ + return TRUE; \ } -#define CHAIN_MSG_MAP(theChainClass) \ - { \ +#define CHAIN_MSG_MAP(theChainClass) \ + { \ if (theChainClass::ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult)) \ - return TRUE; \ + return TRUE; \ } -#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \ -static ATL::CWndClassInfo& GetWndClassInfo() \ -{ \ - static ATL::CWndClassInfo wc = \ - { \ - { sizeof(WNDCLASSEX), style, StartWindowProc, \ - 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ - NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ - }; \ - return wc; \ +#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd) \ +static ATL::CWndClassInfo& GetWndClassInfo() \ +{ \ + static ATL::CWndClassInfo wc = \ + { \ + { sizeof(WNDCLASSEX), style, StartWindowProc, \ + 0, 0, NULL, NULL, NULL, (HBRUSH)(bkgnd + 1), NULL, WndClassName, NULL }, \ + NULL, NULL, IDC_ARROW, TRUE, 0, _T("") \ + }; \ + return wc; \ } struct _ATL_WNDCLASSINFOW