user32: Don't start menu tracking when the owner window is invalid.
This commit is contained in:
parent
354a74e004
commit
bd1fab7862
|
@ -1848,6 +1848,11 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id, UINT flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* store the owner for DrawItem */
|
/* store the owner for DrawItem */
|
||||||
|
if (!IsWindow( hwndOwner ))
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
menu->hwndOwner = hwndOwner;
|
menu->hwndOwner = hwndOwner;
|
||||||
|
|
||||||
menu->nScrollPos = 0;
|
menu->nScrollPos = 0;
|
||||||
|
|
|
@ -2932,6 +2932,20 @@ static void test_menu_trackpopupmenu(void)
|
||||||
gflag_initmenupopup ? " WM_INITMENUPOPUP ": " ",
|
gflag_initmenupopup ? " WM_INITMENUPOPUP ": " ",
|
||||||
gflag_entermenuloop ? "WM_INITMENULOOP ": "",
|
gflag_entermenuloop ? "WM_INITMENULOOP ": "",
|
||||||
gflag_initmenu ? "WM_INITMENU": "");
|
gflag_initmenu ? "WM_INITMENU": "");
|
||||||
|
|
||||||
|
/* invalid window */
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0;
|
||||||
|
ret = MyTrackPopupMenu( Ex, hmenu, TPM_RETURNCMD, 100,100, 0, NULL);
|
||||||
|
gle = GetLastError();
|
||||||
|
ok( !ret, "TrackPopupMenu%s should have failed\n", Ex ? "Ex" : "");
|
||||||
|
ok( gle == ERROR_INVALID_WINDOW_HANDLE, "TrackPopupMenu%s error got %u\n", Ex ? "Ex" : "", gle );
|
||||||
|
ok( !(gflag_initmenupopup || gflag_entermenuloop || gflag_initmenu),
|
||||||
|
"got unexpected message(s)%s%s%s\n",
|
||||||
|
gflag_initmenupopup ? " WM_INITMENUPOPUP ": " ",
|
||||||
|
gflag_entermenuloop ? "WM_INITMENULOOP ": "",
|
||||||
|
gflag_initmenu ? "WM_INITMENU": "");
|
||||||
|
|
||||||
/* now a somewhat successful call */
|
/* now a somewhat successful call */
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0;
|
gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = 0;
|
||||||
|
|
Loading…
Reference in New Issue