diff --git a/dll/win32/atl/atl30.c b/dll/win32/atl/atl30.c index 254dbadb084..5d5cd52b616 100644 --- a/dll/win32/atl/atl30.c +++ b/dll/win32/atl/atl30.c @@ -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; } diff --git a/modules/rostests/winetests/atl/module.c b/modules/rostests/winetests/atl/module.c index 44aecf04577..f176d070b3c 100644 --- a/modules/rostests/winetests/atl/module.c +++ b/modules/rostests/winetests/atl/module.c @@ -25,6 +25,7 @@ #define COBJMACROS #include +#include #include @@ -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(); } diff --git a/sdk/include/reactos/wine/atlwin.h b/sdk/include/reactos/wine/atlwin.h index 099f48bcb52..de31f403ba7 100644 --- a/sdk/include/reactos/wine/atlwin.h +++ b/sdk/include/reactos/wine/atlwin.h @@ -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);