We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3804 - Message box on Windows truncates button ID
Summary: Message box on Windows truncates button ID
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: All Windows (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-07 20:13 UTC by Simon Hug
Modified: 2018-03-24 17:27 UTC (History)
0 users

See Also:


Attachments
Fixes some issues with the windows message box. (15.15 KB, patch)
2017-09-07 20:13 UTC, Simon Hug
Details | Diff
msgboxtest1.c to test SDL_ShowMessageBox. (13.92 KB, text/x-csrc)
2017-09-07 20:15 UTC, Simon Hug
Details
Screenshots of the message box on various Windows versions. (163.23 KB, image/png)
2017-09-07 20:19 UTC, Simon Hug
Details
Patch that fixes id issues and adds icons to the old version of the windows message boxes. (19.33 KB, patch)
2018-03-23 21:59 UTC, Simon Hug
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Hug 2017-09-07 20:13:45 UTC
Created attachment 2913 [details]
Fixes some issues with the windows message box.

I just wanted to fix a simple compiler warning in SDL_ShowMessageBox on Windows (which Sam fixed recently) and ended up finding some issues.

Attached patch fixes these issues:

- Because Windows only reports the lower 16 bits of the control identifier that was pushed, the button IDs used by SDL (C type int, most likely 32 bits) can get cut off.

- The documentation states (somewhat ambiguously) that the button ID will be -1 if the dialog was closed, but the current code sets 0. For SDL 2.1, I think this should be a return code of SDL_ShowMessageBox itself. That will free up the button ID and it seems a more appropriate place for signaling this event.

- Ampersands in controls will create mnemonics on Windows (underlined letters that, if combined with the Alt key, will push the button). I was thinking of adding a hint or flag to let the users enable it, but that might have unexpected results.

- When the size of the text gets calculated, it doesn't use the same parameters as the static control. This can cut off text or wrap it weirdly.

- On Windows, the Tab key is used to switch between control groups and sometimes between buttons in dialogs. This didn't seem to work correctly.

Attached patch also adds:

- Icons. Just the system ones that can be loaded with the ordinals IDI_ERROR, IDI_WARNING and IDI_INFORMATION.

- A button limit of 2^16 - 101.

- Some more specific error messages, but they never reach the user because how SDL_ShowMessageBox handles them if an implementation returns with an error.
Comment 1 Simon Hug 2017-09-07 20:15:36 UTC
Created attachment 2914 [details]
msgboxtest1.c to test SDL_ShowMessageBox.

Attaching a test program for SDL_ShowMessageBox. Description is in the C file.
Comment 2 Simon Hug 2017-09-07 20:19:38 UTC
Created attachment 2915 [details]
Screenshots of the message box on various Windows versions.

The attached image shows how the message box with the icon now appears on various Windows versions. I don't know why Windows 8.1 has such ugly ones. I do have Vista lying around somewhere, but does anyone still care about that?
Comment 3 Simon Hug 2018-03-23 21:59:54 UTC
Created attachment 3194 [details]
Patch that fixes id issues and adds icons to the old version of the windows message boxes.

Updated patch to apply to tip.
Comment 4 Sam Lantinga 2018-03-24 17:27:03 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/f21a2cd69acf