1. Computing

Random Colors Piano Bar

Fancy Delphi Application Contest Entry #3 by Don Rowlett

From , former About.com Guide

Random Colors Piano - Fancy Delphi Application Contest Entry #3

Random Colors Piano - Fancy Delphi Application Contest Entry #3

The piano is a musical instrument played by means of a keyboard that produces sound by striking steel strings with felt hammers.

Imagine steel strings are color bars, imagine every color producing a different random sound .. and we have a new entry for the Fancy Delphi Application Contest.

Rate this FDAC Entry!

Random Colors Piano

This silly little program creates labels (TLabel) at run time and paints them using a random color. Labels are placed in a control array. When you hover your mouse over the label a sound is played.

Here's the main program's source section:

 var
   Lab: Array[1..65] of TLabel;
 
 .....
 
 procedure CreatePiano;
 var
   k: Byte;
 begin
   for k:= 1 to 65 do Lab[k].Color:= Random(16777216) ;
 end;
 
 procedure TRndLabColForm.FormCreate(Sender: TObject) ;
 var
   k: Byte;
 begin
   Randomize;
   for k:= 1 to 65 do
   begin
     Lab[k]:= TLabel.Create(Self) ;
     Lab[k].Parent := Self;
     Lab[k].Left := 8 + 11*(k-1) ;
     Lab[k].Color:= Random(16777216) ;
     Lab[k].OnMouseEnter:= BarClick;
   end;
 end;
 
 procedure TRndLabColForm.BarClick(Sender: TObject) ;
 begin
   Application.ProcessMessages;
 
   with Sender as TLabel do
      Windows.Beep(440 + (Color div 3500), 100) ;
 end;
 

"Random Colors Piano" was submitted by "Don Rowlett".

Do you have a FDA(C)? Submit your Delphi code to the Fancy Delphi Application Contest.

©2013 About.com. All rights reserved.