Make CreateWindow with invalid menu handle test pass on Wine.

This commit is contained in:
Dmitry Timoshkov 2005-08-09 10:22:45 +00:00 committed by Alexandre Julliard
parent 1766483e4c
commit 4ffc11ad0e
3 changed files with 16 additions and 7 deletions

View File

@ -3790,6 +3790,7 @@ BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu )
if (hMenu && !IsMenu(hMenu))
{
WARN("hMenu %p is not a menu handle\n", hMenu);
SetLastError(ERROR_INVALID_MENU_HANDLE);
return FALSE;
}
if (!WIN_ALLOWED_MENU(GetWindowLongW( hWnd, GWL_STYLE )))

View File

@ -2813,16 +2813,16 @@ static void test_params(void)
rc = GetWindowText(hwndMain2, NULL, 1024);
ok( rc==0, "GetWindowText: rc=%d err=%ld\n",rc,GetLastError());
SetLastError(0xdeadbeef);
hwnd=CreateWindow("LISTBOX", "TestList",
(LBS_STANDARD & ~LBS_SORT),
0, 0, 100, 100,
NULL, (HMENU)1, NULL, 0);
todo_wine {
ok(hwnd==NULL, "CreateWindow(parent=NULL, ctlid!=0) should have failed\n");
}
/* NT sets LastError to ERROR_INVALID_MENU_HANDLE
* but Win9x leaves it unchanged. So no test.
*/
ok(!hwnd, "CreateWindow with invalid menu handle should fail\n");
ok(GetLastError() == ERROR_INVALID_MENU_HANDLE || /* NT */
GetLastError() == 0xdeadbeef, /* Win9x */
"wrong last error value %ld\n", GetLastError());
}
static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)

View File

@ -1025,7 +1025,15 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, ATOM classAtom,
if (((wndPtr->dwStyle & (WS_CAPTION|WS_CHILD)) == WS_CAPTION) ||
(wndPtr->dwExStyle & WS_EX_APPWINDOW))
{
if (cs->hMenu) MENU_SetMenu(hwnd, cs->hMenu);
if (cs->hMenu)
{
if (!MENU_SetMenu(hwnd, cs->hMenu))
{
WIN_ReleasePtr( wndPtr );
free_window_handle( hwnd );
return 0;
}
}
else
{
LPCSTR menuName = (LPCSTR)GetClassLongPtrA( hwnd, GCLP_MENUNAME );