Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
01bf37d8
Commit
01bf37d8
authored
Apr 18, 2006
by
Michael Kaufmann
Committed by
Alexandre Julliard
Apr 19, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user: Find popup menus by ID.
- Find menus by ID: Proper fallback to popup menus. - Use the menu ID, not the handle for the fallback. - Save the fallback menu's position.
parent
04da3ce2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
2 deletions
+74
-2
menu.c
dlls/user/menu.c
+11
-2
menu.c
dlls/user/tests/menu.c
+63
-0
No files found.
dlls/user/menu.c
View file @
01bf37d8
...
...
@@ -580,6 +580,7 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
{
POPUPMENU
*
menu
;
MENUITEM
*
fallback
=
NULL
;
UINT
fallback_pos
=
0
;
UINT
i
;
if
((
*
hmenu
==
(
HMENU
)
0xffff
)
||
(
!
(
menu
=
MENU_GetMenu
(
*
hmenu
))))
return
NULL
;
...
...
@@ -602,8 +603,12 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
*
hmenu
=
hsubmenu
;
return
subitem
;
}
if
((
UINT_PTR
)
item
->
hSubMenu
==
*
nPos
)
fallback
=
item
;
/* fallback to this item if nothing else found */
else
if
(
item
->
wID
==
*
nPos
)
{
/* fallback to this item if nothing else found */
fallback_pos
=
i
;
fallback
=
item
;
}
}
else
if
(
item
->
wID
==
*
nPos
)
{
...
...
@@ -612,6 +617,10 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags )
}
}
}
if
(
fallback
)
*
nPos
=
fallback_pos
;
return
fallback
;
}
...
...
dlls/user/tests/menu.c
View file @
01bf37d8
...
...
@@ -1410,6 +1410,69 @@ void test_menu_search_bycommand( void )
ok
(
rc
,
"Getting the menus info failed
\n
"
);
ok
(
info
.
wID
==
(
UINT
)
hmenuSub2
,
"IDs differ for popup menu
\n
"
);
ok
(
!
strcmp
(
info
.
dwTypeData
,
"Submenu2"
),
"Returned item has wrong label (%s)
\n
"
,
info
.
dwTypeData
);
DestroyMenu
(
hmenu
);
DestroyMenu
(
hmenuSub
);
DestroyMenu
(
hmenuSub2
);
/*
Case 5: Menu containing a popup menu which in turn
contains an item with a different id than the popup menu.
This tests the fallback to a popup menu ID.
*/
hmenu
=
CreateMenu
();
hmenuSub
=
CreateMenu
();
rc
=
AppendMenu
(
hmenu
,
MF_POPUP
|
MF_STRING
,
(
UINT_PTR
)
hmenuSub
,
"Submenu"
);
ok
(
rc
,
"Appending the popup menu to the main menu failed
\n
"
);
rc
=
AppendMenu
(
hmenuSub
,
MF_STRING
,
102
,
"Item"
);
ok
(
rc
,
"Appending the item to the popup menu failed
\n
"
);
/* Set the ID for hmenuSub */
info
.
cbSize
=
sizeof
(
info
);
info
.
fMask
=
MIIM_ID
;
info
.
wID
=
101
;
rc
=
SetMenuItemInfo
(
hmenu
,
0
,
TRUE
,
&
info
);
ok
(
rc
,
"Setting the ID for the popup menu failed
\n
"
);
/* Check if the ID has been set */
info
.
wID
=
0
;
rc
=
GetMenuItemInfo
(
hmenu
,
0
,
TRUE
,
&
info
);
ok
(
rc
,
"Getting the ID for the popup menu failed
\n
"
);
ok
(
info
.
wID
==
101
,
"The ID for the popup menu has not been set
\n
"
);
/* Prove getting the item info via ID returns the popup menu */
memset
(
&
info
,
0
,
sizeof
(
info
));
strback
[
0
]
=
0x00
;
info
.
cbSize
=
sizeof
(
MENUITEMINFO
);
info
.
fMask
=
MIIM_STRING
|
MIIM_ID
;
info
.
dwTypeData
=
strback
;
info
.
cch
=
sizeof
(
strback
);
rc
=
GetMenuItemInfo
(
hmenu
,
101
,
FALSE
,
&
info
);
ok
(
rc
,
"Getting the menu info failed
\n
"
);
ok
(
info
.
wID
==
101
,
"IDs differ
\n
"
);
ok
(
!
strcmp
(
info
.
dwTypeData
,
"Submenu"
),
"Returned item has wrong label (%s)
\n
"
,
info
.
dwTypeData
);
/* Also look for the menu item */
memset
(
&
info
,
0
,
sizeof
(
info
));
strback
[
0
]
=
0x00
;
info
.
cbSize
=
sizeof
(
MENUITEMINFO
);
info
.
fMask
=
MIIM_STRING
|
MIIM_ID
;
info
.
dwTypeData
=
strback
;
info
.
cch
=
sizeof
(
strback
);
rc
=
GetMenuItemInfo
(
hmenu
,
102
,
FALSE
,
&
info
);
ok
(
rc
,
"Getting the menu info failed
\n
"
);
ok
(
info
.
wID
==
102
,
"IDs differ
\n
"
);
ok
(
!
strcmp
(
info
.
dwTypeData
,
"Item"
),
"Returned item has wrong label (%s)
\n
"
,
info
.
dwTypeData
);
DestroyMenu
(
hmenu
);
DestroyMenu
(
hmenuSub
);
}
START_TEST
(
menu
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment