fix: replace MB_SYSTEMMODAL with MB_SETFOREGROUND in MessageDialog#5062
fix: replace MB_SYSTEMMODAL with MB_SETFOREGROUND in MessageDialog#5062majiayu000 wants to merge 2 commits intowailsapp:masterfrom
Conversation
MB_SYSTEMMODAL prevents the dialog from inheriting the parent window's title bar icon on Windows. MB_SETFOREGROUND keeps the dialog in the foreground while allowing it to properly display the owner window's icon. Fixes wailsapp#3684 Signed-off-by: majiayu000 <1835304752@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis change replaces MB_SYSTEMMODAL with MB_SETFOREGROUND in the Windows MessageDialog call and adds error handling; a changelog entry documents the fix. (No exported signatures changed.) Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.16.4)v2/internal/frontend/desktop/windows/dialog.go┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m �[1m Loading rules from local config...�[0m Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for digging into this — it's been open for a while and the root cause analysis in your issue comment is solid. I have a few questions before this can move out of draft: Does
Is the modal behaviour change intentional?
What happened to the In your comment on #3684 you outlined a more complete fix: use Happy to merge something simple if it works — just need Windows verification first. Could you mark ready for review once you've confirmed the icon renders correctly? |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@v2/internal/frontend/desktop/windows/dialog.go`:
- Line 194: The call to windows.MessageBox currently discards its error return;
modify the call in dialog.go to capture both returns (e.g., button, err :=
windows.MessageBox(...)), check if err != nil and return or wrap that error from
the enclosing function (the function that calls getHandleForDialog and
MessageBox), otherwise continue returning the button result; update any callers
or return types if necessary so failures from windows.MessageBox are propagated
instead of masked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 230657c7-3beb-4e0d-9f61-2322fc72e6ba
📒 Files selected for processing (2)
v2/internal/frontend/desktop/windows/dialog.gowebsite/src/pages/changelog.mdx
Signed-off-by: majiayu000 <1835304752@qq.com>
|
Closing this PR — after reviewing the feedback, I agree that |
Fixes #3684
Problem
MessageDialogon Windows doesn't show the parent window's icon in the dialog title bar. TheMB_SYSTEMMODALflag creates a system-level modal that doesn't associate with the owner window, so the icon is not inherited.Fix
Replace
MB_SYSTEMMODALwithMB_SETFOREGROUNDindialog.go.MB_SETFOREGROUNDkeeps the dialog prominent in the foreground while allowing it to inherit the owner window's icon. The parent HWND is already correctly passed viagetHandleForDialog(), so application-modal behavior is preserved.Test Plan
GOOS=windows go buildcalculateMessageDialogFlags()tests unaffected (that function doesn't touch this flag)Summary by CodeRabbit
Bug Fixes
Documentation