[ATL] atlwin.h: Formatting, and add a comment in IsParentDialog().

This commit is contained in:
Hermès Bélusca-Maïto 2021-12-27 19:48:19 +01:00
parent fcc222c28a
commit e60a4f00b5
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -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<char *>(proc) - (reinterpret_cast<char *>(this) + sizeof(thunkCode)));
m_relproc = DWORD(reinterpret_cast<char*>(proc) - (reinterpret_cast<char*>(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<TBase> *pThis;
CDialogImplBaseT<TBase>* 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<DLGPROC>(pThis->m_thunk.GetWNDPROC());
pOldProc = reinterpret_cast<DLGPROC>(::SetWindowLongPtr(hWnd, DWLP_DLGPROC, reinterpret_cast<LONG_PTR>(newDlgProc)));
@ -1363,7 +1364,7 @@ public:
static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CDialogImplBaseT<TBase> *pThis = reinterpret_cast<CDialogImplBaseT<TBase>*>(hWnd);
CDialogImplBaseT<TBase>* pThis = reinterpret_cast<CDialogImplBaseT<TBase>*>(hWnd);
_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
LRESULT lResult = 0;
const _ATL_MSG *previousMessage;
@ -1410,7 +1411,7 @@ public:
template <class T, class TBase = CWindow>
class CDialogImpl : public CDialogImplBaseT< TBase >
class CDialogImpl : public CDialogImplBaseT<TBase>
{
public:
// + Hacks for gcc
@ -1488,7 +1489,7 @@ public:
ATLASSERT(m_hWnd == NULL);
ATLASSERT(::IsWindow(hWnd));
CWindowImplBaseT<TBase, TWinTraits> *pThis;
CWindowImplBaseT<TBase, TWinTraits>* pThis;
pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
BOOL result = m_thunk.Init(GetWindowProc(), this);
@ -1545,22 +1546,22 @@ public:
LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CWindowImplBaseT<TBase, TWinTraits> *pThis;
pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits> *>(this);
CWindowImplBaseT<TBase, TWinTraits>* pThis;
pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(this);
return ::CallWindowProc(m_pfnSuperWindowProc, pThis->m_hWnd, uMsg, wParam, lParam);
}
static LRESULT CALLBACK StartWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CWindowImplBaseT<TBase, TWinTraits> *pThis;
CWindowImplBaseT<TBase, TWinTraits>* pThis;
WNDPROC newWindowProc;
WNDPROC GCCU(pOldProc);
pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits> *>(_AtlWinModule.ExtractCreateWndData());
pThis = reinterpret_cast<CWindowImplBaseT<TBase, TWinTraits>*>(_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<WNDPROC>(::SetWindowLongPtr(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(newWindowProc)));
@ -1571,7 +1572,7 @@ public:
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
CWindowImplBaseT<TBase, TWinTraits> *pThis = reinterpret_cast<CWindowImplBaseT< TBase, TWinTraits> *>(hWnd);
CWindowImplBaseT<TBase, TWinTraits>* pThis = reinterpret_cast<CWindowImplBaseT< TBase, TWinTraits>*>(hWnd);
_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
LRESULT lResult;
const _ATL_MSG *previousMessage;
@ -1605,8 +1606,10 @@ public:
pThis->m_dwState |= WINSTATE_DESTROYED;
}
else
{
lResult = pThis->DefWindowProc(uMsg, wParam, lParam);
}
}
ATLASSERT(pThis->m_pCurrentMsg == &msg);
pThis->m_pCurrentMsg = previousMessage;
if (previousMessage == NULL && (pThis->m_dwState & WINSTATE_DESTROYED) != 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,7 +1661,6 @@ public:
using CWindowImplRoot<TBase>::m_hWnd;
// - Hacks for gcc
static LPCTSTR GetWndCaption()
{
return NULL;
@ -1666,7 +1669,7 @@ public:
HWND Create(HWND hWndParent, _U_RECT rect = NULL, LPCTSTR szWindowName = NULL, DWORD dwStyle = 0,
DWORD dwExStyle = 0, _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL)
{
CWindowImplBaseT<TBase, TWinTraits> *pThis;
CWindowImplBaseT<TBase, TWinTraits>* 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<TBase> *pThis;
pThis = reinterpret_cast<CContainedWindowT<TBase> *>(this);
CContainedWindowT<TBase>* pThis;
pThis = reinterpret_cast<CContainedWindowT<TBase>*>(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<TBase> *pThis;
CContainedWindowT<TBase>* pThis;
WNDPROC newWindowProc;
WNDPROC GCCU(pOldProc);
pThis = reinterpret_cast<CContainedWindowT<TBase> *>(_AtlWinModule.ExtractCreateWndData());
pThis = reinterpret_cast<CContainedWindowT<TBase>*>(_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<TBase> *pThis = reinterpret_cast<CContainedWindowT<TBase> *>(hWnd);
CContainedWindowT<TBase>* pThis = reinterpret_cast<CContainedWindowT<TBase>*>(hWnd);
_ATL_MSG msg(pThis->m_hWnd, uMsg, wParam, lParam);
LRESULT lResult;
const _ATL_MSG *previousMessage;
@ -1909,7 +1913,7 @@ public:
}
#define NOTIFY_CODE_HANDLER(cd, func) \
if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
{ \
bHandled = TRUE; \
lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \
@ -1918,7 +1922,7 @@ public:
}
#define NOTIFY_HANDLER(id, cd, func) \
if(uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \
if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom && cd == ((LPNMHDR)lParam)->code) \
{ \
bHandled = TRUE; \
lResult = func((int)wParam, (LPNMHDR)lParam, bHandled); \