| 537 | // Ok, trying to use window subclassing to handle messages |
| 538 | |
| 539 | LRESULT CALLBACK subclass_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param, UINT_PTR /*u_id_subclass*/, DWORD_PTR /*dw_ref_data*/) { |
| 540 | LRESULT ret; // int->LRESULT, fix x64 issue, still compatible with x86 |
| 541 | switch (message) { |
| 542 | case WM_INITMENUPOPUP: { |
| 543 | // Checking that it isn't system menu and nor any main menu except 0th |
| 544 | if (!cur_menu_list.empty() && LOWORD(l_param) == 0 && HIWORD(l_param) == 0) { |
| 545 | // Special check for 0th main menu item |
| 546 | MENUBARINFO info; |
| 547 | info.cbSize = sizeof(MENUBARINFO); |
| 548 | GetMenuBarInfo(npp_data.npp_handle, OBJID_MENU, 0, &info); |
| 549 | HMENU main_menu = info.hMenu; |
| 550 | MENUITEMINFO file_menu_item; |
| 551 | file_menu_item.cbSize = sizeof(MENUITEMINFO); |
| 552 | file_menu_item.fMask = MIIM_SUBMENU; |
| 553 | GetMenuItemInfo(main_menu, 0, TRUE, &file_menu_item); |
| 554 | |
| 555 | const auto menu = reinterpret_cast<HMENU>(w_param); |
| 556 | if (file_menu_item.hSubMenu != menu && get_langs_sub_menu() != menu) { |
| 557 | MenuItem::prepend_to_menu(menu, cur_menu_list); |
| 558 | } |
| 559 | } |
| 560 | cur_menu_list.clear(); |
| 561 | } |
| 562 | break; |
| 563 | |
| 564 | case WM_COMMAND: |
| 565 | if (HIWORD(w_param) == 0) { |
| 566 | if (!get_use_allocated_ids()) |
| 567 | context_menu_handler->process_menu_result(w_param); |
| 568 | |
| 569 | if (LOWORD(w_param) == IDM_FILE_PRINTNOW || LOWORD(w_param) == IDM_FILE_PRINT) { |
| 570 | // Disable autocheck while printing |
| 571 | const bool was_auto_check_on = get_settings().data.auto_check_text; |
| 572 | |
| 573 | if (was_auto_check_on) { |
| 574 | auto mut_settings = get_settings().modify_without_saving(); |
| 575 | mut_settings->data.auto_check_text = false; |
| 576 | } |
| 577 | |
| 578 | ret = ::DefSubclassProc(h_wnd, message, w_param, l_param); |
| 579 | |
| 580 | if (was_auto_check_on) { |
| 581 | auto mut_settings = get_settings().modify_without_saving(); |
| 582 | mut_settings->data.auto_check_text = true; |
| 583 | } |
| 584 | |
| 585 | return ret; |
| 586 | } |
| 587 | } |
| 588 | break; |
| 589 | case WM_NOTIFY: |
| 590 | // Removing possibility of adding items to tab bar menu. |
| 591 | if (reinterpret_cast<LPNMHDR>(l_param)->code == NM_RCLICK) { |
| 592 | cur_menu_list.clear(); |
| 593 | } |
| 594 | break; |
| 595 | case WM_CONTEXTMENU: |
| 596 | last_hwnd = w_param; |
nothing calls this directly
no test coverage detected