Commit 1d0bb921 authored by jam@chromium.org's avatar jam@chromium.org

Fix regression in submenus not working.

BUG=69797
Review URL: http://codereview.chromium.org/6304013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72005 0039d316-1c4b-4281-b951-d872f2087c98
parent 09205efb
...@@ -88,6 +88,14 @@ class NativeMenuWin::MenuHostWindow { ...@@ -88,6 +88,14 @@ class NativeMenuWin::MenuHostWindow {
registered = true; registered = true;
} }
NativeMenuWin* GetNativeMenuWinFromHMENU(HMENU hmenu) const {
MENUINFO mi = {0};
mi.cbSize = sizeof(mi);
mi.fMask = MIM_MENUDATA | MIM_STYLE;
GetMenuInfo(hmenu, &mi);
return reinterpret_cast<NativeMenuWin*>(mi.dwMenuData);
}
// Converts the WPARAM value passed to WM_MENUSELECT into an index // Converts the WPARAM value passed to WM_MENUSELECT into an index
// corresponding to the menu item that was selected. // corresponding to the menu item that was selected.
int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const { int GetMenuItemIndexFromWPARAM(HMENU menu, WPARAM w_param) const {
...@@ -116,15 +124,20 @@ class NativeMenuWin::MenuHostWindow { ...@@ -116,15 +124,20 @@ class NativeMenuWin::MenuHostWindow {
// Called when the user selects a specific item. // Called when the user selects a specific item.
void OnMenuCommand(int position, HMENU menu) { void OnMenuCommand(int position, HMENU menu) {
parent_->model_->ActivatedAt(position); NativeMenuWin* intergoat = GetNativeMenuWinFromHMENU(menu);
ui::MenuModel* model = intergoat->model_;
model->ActivatedAt(position);
} }
// Called as the user moves their mouse or arrows through the contents of the // Called as the user moves their mouse or arrows through the contents of the
// menu. // menu.
void OnMenuSelect(WPARAM w_param, HMENU menu) { void OnMenuSelect(WPARAM w_param, HMENU menu) {
if (!menu)
return; // menu is null when closing on XP.
int position = GetMenuItemIndexFromWPARAM(menu, w_param); int position = GetMenuItemIndexFromWPARAM(menu, w_param);
if (position >= 0) if (position >= 0)
parent_->model_->HighlightChangedTo(position); GetNativeMenuWinFromHMENU(menu)->model_->HighlightChangedTo(position);
} }
// Called by Windows to measure the size of an owner-drawn menu item. // Called by Windows to measure the size of an owner-drawn menu item.
......
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