From f7e3030f3438f92e92dfa724c5f8a6864387de0f Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 20 Sep 2023 22:00:27 +0300 Subject: [PATCH] fix(windows): redraw menubar after inserting (#125) --- .changes/windows-menubar-redraw.md | 5 +++++ src/platform_impl/windows/mod.rs | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changes/windows-menubar-redraw.md diff --git a/.changes/windows-menubar-redraw.md b/.changes/windows-menubar-redraw.md new file mode 100644 index 00000000..722b193c --- /dev/null +++ b/.changes/windows-menubar-redraw.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +On Windwos, redraw the menubar when adding a new menu item or a submenu. diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index 2add8baf..0beca38a 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -248,6 +248,11 @@ impl Menu { } } + // redraw the menu bar + for hwnd in &self.hwnds { + unsafe { DrawMenuBar(*hwnd) }; + } + { let mut child_ = child.borrow_mut(); child_.parents_hemnu.push(self.hmenu); @@ -270,6 +275,7 @@ impl Menu { RemoveMenu(self.hmenu, id, MF_BYCOMMAND); RemoveMenu(self.hpopupmenu, id, MF_BYCOMMAND); + // redraw the menu bar for hwnd in &self.hwnds { DrawMenuBar(*hwnd); }