Stephen Smith's Blog

All things Sage 300…

Colorful Companies in Sage 300 ERP

with 7 comments


We released Sage 300 ERP 2012 back in September, 2012 and now are preparing to release our Product Update 1. This PU1 will have a number of bug fixes along with a number of new features. In this blog article I’m going to explore one of the new features that allows you to choose the color of the title bar and border on your Sage 300 Windows by company.

Many of our users have data stored in multiple Sage 300 databases. Often they are comparing this data or copying it from one company to the other. Often they end up with several desktops open along with many screens. The company name is always part of the title bar, but this is quite subtle and it’s easy to do tasks in the wrong company as a result. This feature makes it more obvious which window belongs to which company with a stronger visual indicator, namely the color of the title bar and window boarder.


You configure the color of the company using Database Setup. The list of companies now includes a column for the company’s color. There is an option you can click to automatically assign colors to all your companies. Or you can clear all the colors and go back to no colors.


If you want to select each companies color yourself then you do this by editing the individual company.


Note that when a color is chosen we take over drawing the title bar and window border to draw the color. If you want the natural Window look then don’t select a color and we won’t touch the title bar or border allowing Windows to do its default drawing.


Once configured you will get Desktops and screens looking like:


Notice that even the little preview windows when you hover over the taskbar icons show the colors.

Development Notes

Windows doesn’t provide any easy API for coloring the title bar or border of a Window. This area is referred to as the non-client area and the best it gives you is a hook to take over painting the entire area. This means you have to also paint the buttons for minimize, maximize and close as well as the system menu and draw the various states of these. Plus you have to then draw the title text and handle whether to use white or black depending on the color selected.

If you’ve ever run the Chrome or Firefox browsers, you may have noticed that they support themes which among other things take over the drawing of the non-client area. The neat thing then is that since these are open source projects, you can download their source code and see how they do it. The main thing for us was that we got confirmation that there wasn’t an easier way to do it and that what we were doing was a reasonable approach.

For this exercise we wanted to get the right balance of visual difference to not causing too jarring a change. We considered changing things like the form background, but in our opinion this was too drastic and didn’t work well with all color combinations. This approach also doesn’t interfere with the various Windows accessibility options so you can still use high contrast modes and such.

The way we implemented the change was to put the code into the regular desktop, as well as the a4wcontainer. The a4wcontainer acts as a COM host to host our screen ActiveX controls. Each accounting screen is written in Visual Basic and compiled as an ActiveX control. This way it can be embedded in other programs and customized via the API it exposes. But when running normally, when the desktop is asked to run a VB form, it launches a4wcontainer and that then acts as a COM container for hosting the ActiveX control. It is actually the COM container that is responsible for drawing the non-client area, so all we had to do is add the drawing code here to then affect all VB screens.

At this point frequent screen customizers might object. Unless you are an SDK application you won’t get this treatment. If you have embedded a screen in another programming system (say VB) and are distributing it as an EXE then you are the COM container and won’t get the benefit of this treatment. Similarly if you run from VBA, we have no control of drawing the VBA non-client area so again you won’t get this treatment. But our feeling was that the current implementation should handle most of the need and a few exceptions was ok.


Our first Product Update for Sage 300 ERP 2012 should be out shortly and this article gives a quick overview of one of the usability features that has been added. Hopefully people find this useful and it will help them perform their work more accurately.

Written by smist08

January 26, 2013 at 6:36 pm

7 Responses

Subscribe to comments with RSS.

  1. Nice, article….it would be even nicer if there’s some sample code!

    James Hutchison

    January 27, 2013 at 5:11 pm

  2. Practical but not very nice looking. If you look at the things you can do in WPF and silverlight and HTML, than this looks as old as the technology behind it. I hope that sage will invest in upgrading the technology behind a wonderful product, as a developer I’m very concerned about the future of sage.

    Francois Taljaard

    January 31, 2013 at 11:43 am

  3. […] Introduction We released Sage 300 ERP 2012 back in September, 2012 and now are preparing to release our Product Update 1. This PU1 will have a number of bug fixes along with a number of new feature…  […]

  4. […] the year by releasing the Sage 300 ERP 2012 Product Update 1. This included new features like Colorful Companies and a major new release of Canadian and US […]

  5. What table is the colour stored in?


    September 30, 2016 at 11:06 am

    • There is a file ColorConfigure.ini in the Sage300\site folder. If you set some colors you can see what it puts there.


      September 30, 2016 at 8:44 pm

      • Cheers. Just what I was looking for. Shame it isn’t held in the database as I need to set some colours in an integrated Sage CRM system based on the database colour. Reading an ini file makes the code quite a bit more convoluted rather than reading the data from a table.


        October 3, 2016 at 10:16 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: