Hacker News new | ask | show | jobs
by mark-r 57 days ago
But it wasn't just one window, there were lots of controls on that window and the relationship between them wasn't as obvious as you'd assume. Trust me, recreating the whole thing from scratch was easier.

The fun part was making a C++ class that could build up an in-memory dialog template. You had to do it that way because it was dynamically sized based on the message you displayed and the buttons you needed. If you used the default colors, you might be able to tell they were different if you squinted but you wouldn't know which was mine and which was Microsoft's.

1 comments

I've done this for real, in commercial code that shipped. No trust needed; I have personal experience. For typical minor MessageBox additions, this can be easier than rebuilding the whole dialog yourself. Sometimes, we just wanted to add a "Don't ask again" checkbox which didn't require touching the existing child windows at all. I also used this technique to simply change the labels on the buttons to custom text. I had a MessageBox wrapper that accepted a list of button strings instead of a predefined constant. We've all built various custom message boxes, of course, but not every situation required that level of effort.

These days you can just use a TaskDialog, of course, and it's way more flexible than MessageBox. But it's fun to remember the old techniques.