@@ -135,7 +135,8 @@ std::vector<std::string> extract_hotkeys(const std::string &name) {
135135
136136menu menu::construct_with_hmenu (
137137 HMENU hMenu, HWND hWnd, bool is_top,
138- std::function<void (int , WPARAM, LPARAM)> HandleMenuMsg) {
138+ std::function<void (int , WPARAM, LPARAM)> HandleMenuMsg,
139+ LPARAM init_popup_lparam) {
139140 menu m;
140141
141142 if (!HandleMenuMsg)
@@ -144,7 +145,7 @@ menu menu::construct_with_hmenu(
144145 };
145146
146147 HandleMenuMsg (WM_INITMENUPOPUP, reinterpret_cast <WPARAM>(hMenu),
147- 0xFFFFFFFF );
148+ init_popup_lparam );
148149 for (int i = 0 ; i < GetMenuItemCount (hMenu); i++) {
149150 menu_item item;
150151 wchar_t buffer[256 ];
@@ -177,13 +178,12 @@ menu menu::construct_with_hmenu(
177178
178179 if (info.hSubMenu ) {
179180 auto main_thread_id = GetCurrentThreadId ();
181+ int submenu_pos = i;
180182 item.submenu = [=](std::shared_ptr<menu_widget> mw) {
181183 auto task = [&]() {
182- HandleMenuMsg (WM_INITMENUPOPUP,
183- reinterpret_cast <WPARAM>(info.hSubMenu ),
184- 0xFFFFFFFF );
185184 mw->init_from_data (menu::construct_with_hmenu (
186- info.hSubMenu , hWnd, false , HandleMenuMsg));
185+ info.hSubMenu , hWnd, false , HandleMenuMsg,
186+ MAKELPARAM (static_cast <WORD>(submenu_pos), 0 )));
187187 };
188188 if (main_thread_id == GetCurrentThreadId ())
189189 task ();
0 commit comments