The 25 days of C++mas - December 12 - Checking 12/12/12 12:12:12.12 with C++Builder

By: David Intersimone

Abstract: David I creates a countdown timer with C++Builder and FireMonkey

This is a copy of a blog post from David I's Sip from the Firehose blog. Click to blog post title below to see the original blog post and comments.

  The 25 days of C++mas - December 12 - Checking 12/12/12 12:12:12.12 with C++Builder

Today is December 12, 2012.  At 12:12:12.12pm (Pacific Time) today at CodeRage 7 C++ Conference, Eli Boling of the C++Builder compiler team will be taking about the newC++Builder 64-bit compiler.  We will stop the session for a quick moment at that time and have a small flash mob inside the Developer Relations studio.  The C++ language standard provides a naming convention to identify language extensions using the double underbar (__) in front of any extensions. This session will discuss the new C++Builder 64-bit compiler architecture and implementation and the language and run-time extensions added to the new C++Builder 64-bit Windows compiler to support Delphi language, types, components and enhanced RTTI [__delphirtti(TMediaType)].

To remind me when we reach 12:12:12:12.12, I have created a C++Builder FireMonkey 2 application.  The main form has a TCheckBox (to turn on the timer), TCalendar (to remind me that it is December 12th today), 4 TLabel(s) (to display labels, current time and remaining time), TImage (to display a bitmap of the end of the world, Visible property set to false), TCrumpleTransitionEffect (to crumple the TImage, Enabled property set to false), TFloatAnimation (to change the Progress property of the Crumple transition, Duration property set to 2 seconds, Start Value set to 0 and Stop Value set to 50) and a TTimer (to update the current time and remaining time, Interval property set to 100 miliseconds between event firings).  Below you will find a screen grab of the IDE FireMonkey form designer and the Structure View.  Click on the image to see a larger bitmap version.

Here is the code for the C++Builder FireMonkey example (compiles and runs on Win32, Win64 and OSX).


#pragma hdrstop

#include "TimerUnit.h"
#include "System.DateUtils.hpp"
#pragma package(smart_init)
#pragma resource "*.fmx"
TForm4 *Form4;
__fastcall TForm4::TForm4(TComponent* Owner)
	: TForm(Owner)
void __fastcall TForm4::TimerCheckBoxChange(TObject *Sender)
  Timer1->Enabled = TimerCheckBox->IsChecked;
void __fastcall TForm4::Timer1Timer(TObject *Sender)
  ClockLabel->Text = FormatDateTime("HH:NN:SS.ZZZ",Now());
  RemainingTimeLabel->Text = FormatDateTime(
  if (Now() > EncodeDateTime(2012,12,12,12,12,12,12)) {
	TimerCheckBox->IsChecked = false;
	Image1->Visible = true;
	CrumpleTransitionEffect1->Enabled = true;
	FloatAnimation1->Enabled = true;

A 12-12-12 12:12:12.12 Update - My C++ program worked!

I recorded my computer screen as the clock approached the "Twelves" time.  You can download the project source code and the rendered screen capture video at This simple example shows you how to use the Timer and an image animation effect.  You can modify the code to support any date and time trigger.  You might use it for a birthday, holiday, New Years Eve celebration.  Instead of an image you could add a FireMonkey 2 TMediaPlayer component and show a video or play an audio clip at a specific date and time.  Since I used an "end of the world" image in the application, you could change the EncodeDateTime (or EncodeDate) function parameter to use 12/21/2012 and be ready for the Mayan end of the world.

CodeRage 7 C++ Conference, December 10-12, 2012

The CodeRage 7 C++ conference starts next Monday, December 10, 2012 at 6am Pacific Standard Time (14:00 UTC). There are 3 days of C++ sessions that run from 6am to 5pm each day. Some of the C++ sessions you won’t want to miss are included in my blog post on November 21 -

Happy C++mas!

During the first 25 days of December leading up to Christmas, I will blog about the release of the C++Builder 64-bit compiler for Microsoft Windows and C++Builder XE3 support for building VCL and FireMonkey 2 (FM2) applications.

Server Response from: ETNASC01