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.
Random Colors PianoThis 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.