MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / UpdateMenuBars

Method UpdateMenuBars

source/script_gui.cpp:2611–2638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2609
2610
2611void GuiType::UpdateMenuBars(HMENU aMenu)
2612// Caller has changed aMenu and wants the change visibly reflected in any windows that that
2613// use aMenu as a menu bar. For example, if a menu item has been disabled, the grey-color
2614// won't show up immediately unless the window is refreshed.
2615{
2616 for (GuiType* gui = g_firstGui; gui; gui = gui->mNextGui)
2617 {
2618 //if (gui->mHwnd) // Always non-NULL for any item in the list.
2619 if (GetMenu(gui->mHwnd) == aMenu && IsWindowVisible(gui->mHwnd))
2620 {
2621 // Neither of the below two calls by itself is enough for all types of changes.
2622 // Thought it's possible that every type of change only needs one or the other, both
2623 // are done for simplicity:
2624 // This first line is necessary at least for cases where the height of the menu bar
2625 // (the number of rows needed to display all its items) has changed as a result
2626 // of the caller's change. In addition, I believe SetWindowPos() must be called
2627 // before RedrawWindow() to prevent artifacts in some cases:
2628 SetWindowPos(gui->mHwnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
2629 // This line is necessary at least when a single new menu item has been added:
2630 RedrawWindow(gui->mHwnd, NULL, NULL, RDW_INVALIDATE|RDW_FRAME|RDW_UPDATENOW);
2631 // RDW_UPDATENOW: Seems best so that the window is in an visible updated state when function
2632 // returns. This is because if the menu bar happens to be two rows or its size is changed
2633 // in any other way, the window dimensions themselves might change, and the caller might
2634 // rely on such a change being visibly finished for PixelGetColor, etc.
2635 //Not enough: UpdateWindow(gui->mHwnd);
2636 }
2637 }
2638}
2639
2640
2641

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected