Commit 5608682d authored by Hermes Belusca-Maito's avatar Hermes Belusca-Maito Committed by Alexandre Julliard

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

parent 433990d6
......@@ -313,7 +313,7 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA
if (!wci->m_wc.lpszClassName)
{
sprintf(wci->m_szAutoName, "ATL%08x", PtrToUint(wci));
sprintf(wci->m_szAutoName, "ATL:%p", wci);
TRACE("auto-generated class name %s\n", wci->m_szAutoName);
wci->m_wc.lpszClassName = wci->m_szAutoName;
}
......@@ -350,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)
......@@ -372,8 +372,7 @@ ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW
if (!wci->m_wc.lpszClassName)
{
static const WCHAR szFormat[] = {'A','T','L','%','0','8','x',0};
swprintf(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), szFormat, PtrToUint(wci));
swprintf(wci->m_szAutoName, ARRAY_SIZE(wci->m_szAutoName), L"ATL:%p", wci);
TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName));
wci->m_wc.lpszClassName = wci->m_szAutoName;
}
......
......@@ -25,6 +25,7 @@
#define COBJMACROS
#include <atlbase.h>
#include <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_PTR cb_val;
static void WINAPI term_callback(DWORD_PTR dw)
......@@ -159,5 +209,6 @@ START_TEST(module)
{
test_StructSize();
test_winmodule();
test_winclassinfo();
test_term();
}
......@@ -29,7 +29,7 @@ typedef struct _ATL_WNDCLASSINFOA_TAG
LPCSTR m_lpszCursorID;
BOOL m_bSystemCursor;
ATOM m_atom;
CHAR m_szAutoName[14];
CHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
} _ATL_WNDCLASSINFOA;
typedef struct _ATL_WNDCLASSINFOW_TAG
......@@ -40,7 +40,7 @@ typedef struct _ATL_WNDCLASSINFOW_TAG
LPCWSTR m_lpszCursorID;
BOOL m_bSystemCursor;
ATOM m_atom;
WCHAR m_szAutoName[14];
WCHAR m_szAutoName[sizeof("ATL:") + sizeof(void *) * 2];
} _ATL_WNDCLASSINFOW;
ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA *wci, WNDPROC *pProc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment