The current ObjectStudio GUI project is bringing considerable innovations to the environment. This month we’re going to have a look at how GDI+ can be used to create an analog clock.

Windows GDI+ is the portion of the Windows operating system that provides two-dimensional vector graphics, imaging and typography. GDI+ improves on the Windows Graphics Device Interface (GDI) (the graphics device interface included with earlier versions of Windows) by adding new features and by optimizing existing features (

Opening the UI

When we open the UI, we first create the main window and then assign three events before drawing anything on it:

  • UIPaintAnnouncement
  • UICloseAnnouncement
  • UIPositionChangedAnnouncement

We create a Timer that runs every second and repaints the main window. The repainting of the main window causes the UIPaintAnnouncement to be announced, and this starts the whole drawing and re-drawing process.

Drawing the Clock

The UIPaintAnnouncement starts the drawing of the clock. This is done on a non-visual buffered bitmap and when the drawing is done, this bitmap is shown on the window.

The drawing is done in layers. We first draw the background Cincom logo, the clock face, the date and finally the hands. The bottom layer is the Cincom logo, which is stored as a JPG file on disk. We do now support JPG and PNG files out of the box, without the need of any decoders.

The clock face is drawn on top of the logo but its background is transparent, so you can see the background picture. It is part of the ARGBColor class that uses the alpha channel for transparency. Transparency values are from 0 (totally invisible) to 255 (solid).

The lines and text are smoothed using anti-aliasing.

Moving the Clock on the Screen and Resizing the Window

The UIPositionChangedAnnouncement gets announced, and this clears the buffered image. The full image gets rebuilt and displayed at the right position after the next Timer cycle.

Closing the Clock

Clears the graphic buffers and releases all GDI+ resources like pens, brushes and fonts.

Code for this example can be made available upon request via the ost-dev mailing list. If you are not already on the list and would like to be added, please contact Product Manager, Arden Thomas, ( since this is where we’ll be delivering ongoing pre-release GUI updates to interested developers. In addition to possibly being of direct use, this clock example is a great example of the vastly increased level of control over Windows API drawing that ObjectStudio users will have using the new GUI interface.