May 23, 2011

Why Can’t I Colour My Dialog Buttons?

Filed under: General — Marcus Tettmar @ 8:45 am

Some people have asked why they can’t change the colour of a button that they place onto a custom dialog.

The short answer is that these buttons are standard Windows buttons and are drawn by Windows. And Windows has some “rules”.

Microsoft lays down some design guidelines. Take a look at this document here which says:

If you use standard windows and Windows controls, these border styles are supplied for your application automatically. If you create your own controls, your application should map the colors of those controls to the appropriate system colors so that the controls fit in the overall design of the interface when the user changes the basic system colors.

So, a standard control, like a dialog button will adopt the colour and design as decided by Windows and the user’s system wide preferences and we as the programmer have little or no control over it. Idealistically this is a good thing.

I believe that convention helps usability. If all buttons look alike a user knows it’s a button and so it’s purpose and functionality is obvious.

Of course, there are exceptions and sometimes there may be a reason (justified or not) for ignoring the guidelines and making a button look like something very different, e.g. in a game. So how do you do it? Well, obviously you don’t use standard Button objects.

On the whole Macro Scheduler dialogs are meant to be just that – standard looking Windows dialogs, designed for requesting data from users or giving them choices and controlling macros.

If you want complete freedom to design something snazzy then arguably you are using the wrong technology and should be considering something like Flash or HTML instead. And there’s no reason why such an interface can’t trigger Macro Scheduler macros anyway.

Having said that there are some things you can do to make more glorified looking dialog “buttons”. One option is to use Image objects. Don’t forget that you can respond to a mouse click on any object, so you can easily have a clickable image. You can trap other events too – such as mouse over events. So if you want to be really clever you can have your image’s mouse over event change the image, e.g. to one with a slightly different border style so that the user knows it is the active “button”.