For Newbie

Tuesday, 15 November 2011

Rinning Animation Text (Marquee) on the Start Button delphi


Create animated text Tricks running on Windows XP Start Button with Delphi.

Design the form:
running text marquee delphi

Add the following components: TEdit (input text start button), TTimer (set animated text) and TTrackBar (change the interval timer).
Learning Delphi - Form Design Animation Running on the Start Button Text

form Design

coding:
Previously, add variable declarations wHnd in private. This variable stores information windowhandle from the Start Button.
   ...
   private
     wHnd: hWnd;
   ...

Main:
/ / Init App to Get StartButton Window Handle
TForm1.FormCreate procedure (Sender: TObject);
begin
   / / Lyrics from Captain Jack - Some Of Us
   Edit1.Text: = 'Some of our brains were dirty,' +
                'because of immoral material crammed ... '+
                'Some of us got greedy,' +
                'because it was taught to worship money ... ';
   TrackBar1.OnChange (Self);
   wHnd: = GetWindow (FindWindow ('Shell_TrayWnd', nil), GW_CHILD or GW_HWNDFIRST);
end;

/ / Update Timer
/ / TrackBar1 Max = 15, Min = 5
TForm1.TrackBar1Change procedure (Sender: TObject);
begin
   Timer1.Interval: = TrackBar1.Position * 10;
end;

/ / Animation Movie
var
   cs: Byte;
TForm1.Timer1Timer procedure (Sender: TObject);
var
   l: Integer;
   s: String;
begin
   l: = Length (Edit1.Text);
   cs: = cs + 1;
   if cs> l then cs: = 0;
   s: = Copy (Edit1.Text, cs, Length (Edit1.Text)) + Copy (Edit1.Text, 1,
       Length (Edit1.Text));
   SetWindowText (wHnd, PChar (s));
   SendMessage (wHnd, WM_SETFOCUS, 0, 0);
end;

TForm1.FormClose procedure (Sender: TObject; var Action: TCloseAction);
begin
   / / Returns the default value text start button
   SetWindowText (wHnd, 'start');
   SendMessage (wHnd, WM_SETFOCUS, 0, 0);
end;

Share on Facebook
Share on Twitter
Share on Google+

Related : Rinning Animation Text (Marquee) on the Start Button delphi