Skip to content

fix(windows): show app icon in MessageDialog via MessageBoxIndirectW - #6250

Open
DangTAnh wants to merge 1 commit into
wailsapp:masterfrom
DangTAnh:pr/3684-messagedialog-icon
Open

DangTAnh wants to merge 1 commit into
wailsapp:masterfrom
DangTAnh:pr/3684-messagedialog-icon

Conversation

@DangTAnh

@DangTAnh DangTAnh commented Oct 12, 2026 •

Copy link
Copy Markdown

Description

MessageBoxW (used by v2 MessageDialog on Windows) takes no icon resource argument — it can only render the four stock icons, so the application icon never appears in the message box and the frame icon never inherits the owner window (#3684). MB_SYSTEMMODAL is orthogonal to icon selection (modality only).

Mirrors the merged v3 fix (#5576): show the message box via MessageBoxIndirectW + MB_USERICON, passing the module handle (GetModuleHandle) and the icon resource id as MAKEINTRESOURCE. Reads winc.AppIconID (mutable via SetAppIcon, defaults to 3) instead of a hardcoded value. Stock-icon bits are stripped (mixed MB_ICON* + MB_USERICON is undefined) while button config and MB_SYSTEMMODAL survive.

If the icon resource is missing (dev builds: go run / wails dev, no embedded .syso), MessageBoxIndirect fails outright (#4233) — falls back to the original MessageBoxW call so the message is still shown.

Custom Icon []byte rendering is unchanged/out of scope (needs TaskDialog; same limitation documented in v3).

Fixes #3684

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Unit: go test -count=1 -run '[Mm]essageDialog' -v ./internal/frontend/desktop/windows/... (7 existing + 6 new flag-conversion cases pass); full package suite ok; gofmt clean on committed blobs; go build ./internal/... ./pkg/runtime/... clean.

Manual UI verification (app icon in dialog body with embedded rsrc.syso; fallback dialog without it) needs a live Windows GUI session — not run here; flag conversion is the only non-trivial logic and is unit-tested.

  • Windows
  • macOS
  • Linux

Test Configuration

wails doctor: Windows 11 (Build 26200), Go 1.26.6, amd64, WebView2 154.0.4258.62, Node 24.19.0, npm 11.17.0.

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes
    • Windows message dialogs now display the application icon. If it can’t be shown, the dialog falls back to a standard system icon.

@github-actions github-actions Bot added Bug Something isn't working v2 Documentation Improvements or additions to documentation Windows labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: wailsapp/wails/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23fc389b-5732-49fa-ad9a-e0575974b56e



📥 Commits

Reviewing files that changed from the base of the PR and between acc71e1 and 06bfb4c.




📒 Files selected for processing (5)
  • v2/internal/frontend/desktop/windows/dialog.go
  • v2/internal/frontend/desktop/windows/dialog_test.go
  • v2/internal/frontend/desktop/windows/winc/w32/typedef.go
  • v2/internal/frontend/desktop/windows/winc/w32/user32.go
  • website/src/pages/changelog.mdx



Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.





Walkthrough

Windows MessageDialog now attempts to display the application icon through MessageBoxIndirectW. If that call returns an error, it falls back to the stock-icon message box. Tests cover the dialog flags, and the changelog records the fix.

Changes

Windows dialog icon

Layer / File(s) Summary
Indirect message-box API
v2/internal/frontend/desktop/windows/winc/w32/typedef.go, v2/internal/frontend/desktop/windows/winc/w32/user32.go
The w32 package adds MSGBOXPARAMS, binds MessageBoxIndirectW, and adds MessageBoxWithIcon to return the API result or syscall error.
Dialog icon and fallback
v2/internal/frontend/desktop/windows/dialog.go, v2/internal/frontend/desktop/windows/dialog_test.go, website/src/pages/changelog.mdx
MessageDialog adds user-icon and system-modal flags, attempts to show the application icon, and falls back to MessageBox on error. Tests cover the flags. The changelog records the fix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 06bfb

No confirmed issue blocks merging. The icon display and missing-resource fallback have not been checked in a live Windows GUI session.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue [#3684] requires the Windows runtime.MessageDialog icon to match the application or parent-window icon. The PR changes the v2 Windows dialog path to call MessageBoxIndirectW with `MB_USERICO…
Out of Scope Changes check Passed The changes stay within issue [#3684]. The dialog update implements icon selection, the MSGBOXPARAMS and MessageBoxIndirectW bindings support that update, the tests verify flag conversion, and the…
Title check Passed The title clearly identifies the Windows MessageDialog fix and the use of MessageBoxIndirectW to show the application icon.
Description check Passed The description covers the issue, implementation, fallback behavior, testing, environment, scope, and checklist. It links issue #3684 and reports that manual Windows UI verification was not performed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR





  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

I’m a rabbit with a dialog to show,
The app’s own icon now joins the flow.
If that first call cannot appear,
A stock icon steps in, bright and clear.
I thump my paws and hop away.

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Documentation Improvements or additions to documentation v2 Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] runtime.MessageDialog frame icon missing windows

1 participant