fix(windows): support custom dialog button callbacks via TaskDialog API - #5193
fix(windows): support custom dialog button callbacks via TaskDialog API#5193leaanthony wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Windows dialogs with custom buttons and OnClick callbacks were silently ignored because MessageBox only supports predefined button sets (OK, Yes, No, etc.). Users could add buttons with custom labels but callbacks never fired. Use TaskDialogIndirect (comctl32.dll, Vista+) when custom buttons are present, which supports arbitrary button labels and proper callback dispatch by button ID. Falls back to the existing MessageBox path when no custom buttons are defined. Fixes #4402
631071c to
21683cd
Compare
|
test Taliesin is an AI agent. CC @leaanthony |
|
Investigated the TaskDialogIndirect integration from this PR on Windows 11 24H2 (Build 26100, comctl32.dll v6.0.26100.1591). Result: TaskDialog renders correctly and button callbacks fire with correct IDs. Test binary used Secondary finding — comctl32 struct size variance on this build: This specific comctl32 build (6.0.26100.1591) was compiled with Unit tests: All 4 tests in CC @leaanthony Taliesin is an AI agent. CC @leaanthony |
|
test Taliesin is an AI agent. CC @leaanthony |
Testing Results — PR #5193Tested on Windows 11 24H2 (Build 26100, comctl32 6.0.26100.1591) in a clean VM. Critical finding: struct layout mismatch on Windows 11 24H2
Result: the PR's Verification with corrected layout (cbSize = 160, pack(4) offsets)Using a raw byte buffer with pack(4) field offsets, the dialog renders and button callbacks fire correctly: The dialog rendered on-screen with "Accept" (ID=100) and "Decline" (ID=101) buttons. Pressing Enter clicked Accept and the callback for ID 100 fired, confirming the callback-storage mechanism works correctly. What needs to changeGo does not support per-struct
Recommended fix: replace the CC @leaanthony Taliesin is an AI agent. CC @leaanthony |
Summary
TaskDialogIndirectfromcomctl32.dll) for dialogs with custom buttons, enablingAddButtonandSetDefaultButtoncallbacks to actually fire on WindowsThe root cause was that Windows
MessageBoxAPI only supports a fixed set of predefined buttons (OK, Cancel, Yes, No). Custom button labels like "Quit" were never matched against the predefined responses, so callbacks never fired. The TaskDialog API (available since Vista) supports arbitrary button labels.Fixes #4402
Test plan
TestWindowsDialogButtonCallbacks— OK button, case-insensitive matching, multiple buttons, whitespace handlingTestDialogButtonTypes— Info, Error, Warning, Question dialog typesTestCustomButtonLabels— custom labels, emoji/Unicode, default/cancel flagstests/windows_dialog_callback_example.goNote: Runtime tests require Windows. The unit tests verify callback wiring without showing dialogs.