[ATL30] Addendum to commit e410a122: Import Wine upstream patch 5608682dc9

atl: Fix the ATL_WNDCLASSINFOW::m_szAutoName member definition and construction.

Signed-off-by: Hermes Belusca-Maito <hermes.belusca@sfr.fr>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hermès Bélusca-Maïto 2020-02-23 16:10:26 +01:00
parent 820dbfccd0
commit b4b0728684
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 58 additions and 20 deletions

View file

@ -313,11 +313,7 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
if (!wci->m_wc.lpszClassName)
{
#ifdef __REACTOS__
sprintf(wci->m_szAutoName, "ATL:%p", wci);
#else
sprintf(wci->m_szAutoName, "ATL%08lx", (UINT_PTR)wci);
#endif
TRACE("auto-generated class name %s\n", wci->m_szAutoName);
wci->m_wc.lpszClassName = wci->m_szAutoName;
}
@ -354,8 +350,8 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
* NOTES
* Can be called multiple times without error, unlike RegisterClassEx().
*
* If the class name is NULL, then a class with a name of "ATLxxxxxxxx" is
* registered, where the 'x's represent a unique value.
* If the class name is NULL, then a class with a name of "ATL:xxxxxxxx" is
* registered, where 'xxxxxxxx' represents a unique hexadecimal value.
*
*/
ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW *wci, WNDPROC *pProc)
@ -376,12 +372,11 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW
if (!wci->m_wc.lpszClassName)
{
#ifdef __REACTOS__
static const WCHAR szFormat[] = {'A','T','L',':','%','p',0};
#ifndef __REACTOS__
swprintf(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), L"ATL:%p", wci);
#else
static const WCHAR szFormat[] = {'A','T','L','%','0','8','l','x',0};
swprintf(wci->m_szAutoName, L"ATL:%p", wci);
#endif
swprintf(wci->m_szAutoName, szFormat, (UINT_PTR)wci);
TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName));
wci->m_wc.lpszClassName = wci->m_szAutoName;
}

View file

@ -25,6 +25,7 @@
#define COBJMACROS
#include <wine/atlbase.h>
#include <wine/atlwin.h>
#include <wine/test.h>
@ -113,6 +114,55 @@ static void test_winmodule(void)
ok(winmod.m_pCreateWndList == create_data+1, "winmod.m_pCreateWndList != create_data\n");
}
static void test_winclassinfo(void)
{
_ATL_MODULEW winmod;
HRESULT hres;
int len, expectedLen;
ATOM atom;
WNDPROC wndProc;
_ATL_WNDCLASSINFOW wci =
{
/* .m_wc = */
{
sizeof(WNDCLASSEXW),
CS_VREDRAW | CS_HREDRAW,
DefWindowProcW,
0,
0,
NULL,
NULL,
LoadCursorW(NULL, (LPCWSTR)IDC_ARROW),
(HBRUSH)(COLOR_BTNFACE + 1),
NULL,
NULL, /* LPCSTR lpszClassName; <-- We force ATL class name generation */
NULL
},
/* .m_lpszOrigName = */ NULL,
/* .pWndProc = */ NULL,
/* .m_lpszCursorID = */ (LPCWSTR)IDC_ARROW,
/* .m_bSystemCursor = */ TRUE,
/* .m_atom = */ 0,
/* .m_szAutoName = */ L""
};
winmod.cbSize = sizeof(winmod);
winmod.m_pCreateWndList = (void*)0xdeadbeef;
hres = AtlModuleInit(&winmod, NULL, NULL);
ok(hres == S_OK, "AtlModuleInit failed: %08x\n", hres);
ok(!winmod.m_pCreateWndList, "winmod.m_pCreateWndList = %p\n", winmod.m_pCreateWndList);
atom = AtlModuleRegisterWndClassInfoW(&winmod, &wci, &wndProc);
ok(atom, "AtlModuleRegisterWndClassInfoA failed: %08x\n", atom);
ok(atom == wci.m_atom, "(atom = %08x) is != than (wci.m_atom = %08x)\n", atom, wci.m_atom);
ok(wcsncmp(wci.m_szAutoName, L"ATL:", 4) == 0, "wci.m_szAutoName = '%ls', expected starting with 'ATL:'\n", wci.m_szAutoName);
len = wcslen(wci.m_szAutoName);
expectedLen = sizeof("ATL:") + sizeof(void *) * 2 - 1;
ok(len == expectedLen, "wci.m_szAutoName has length %d, expected length %d\n", len, expectedLen);
}
static DWORD cb_val;
static void WINAPI term_callback(DWORD dw)
@ -156,5 +206,6 @@ START_TEST(module)
{
test_StructSize();
test_winmodule();
test_winclassinfo();
test_term();
}

View file

@ -29,11 +29,7 @@ typedef struct _ATL_WNDCLASSINFOA_TAG
LPCSTR m_lpszCursorID;
BOOL m_bSystemCursor;
ATOM m_atom;
#ifdef __REACTOS__
CHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2]; // == 4 characters + NULL + number of hexadecimal digits describing a pointer.
#else
CHAR m_szAutoName[14];
#endif
CHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
} _ATL_WNDCLASSINFOA;
typedef struct _ATL_WNDCLASSINFOW_TAG
@ -44,11 +40,7 @@ typedef struct _ATL_WNDCLASSINFOW_TAG
LPCWSTR m_lpszCursorID;
BOOL m_bSystemCursor;
ATOM m_atom;
#ifdef __REACTOS__
WCHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2]; // == 4 characters + NULL + number of hexadecimal digits describing a pointer.
#else
WCHAR m_szAutoName[14];
#endif
WCHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
} _ATL_WNDCLASSINFOW;
ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA *wci, WNDPROC *pProc);