Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Scroll text in title bar of a window Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
26-Jul-03
Category
VCL-Forms
Language
Delphi 2.x
Views
208
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Stefan Pettersson

How to scroll a string of text in the caption of a window, in an editbox or in the 
application''s title so it''s displayed in the Start-menu toolbar (even when the 
form is minimized).

Answer:

It's very simple to scroll a text so it gets displayed in the Start-menu toolbar 
the same way as Winamp scrolls a songs title. 

First two global variables are needed: 

1   var
2     ScrollPosition: integer = 0;
3     ScrollText: string = '     This is the scrolltext...';


The first integer ScrollPosition keep tracks of the current position of the scroll 
text, and the string ScrollText is the actual text that will scroll. A tip is to 
start the scroll text with the same number of spaces as the number of characters 
that will be displayed at the same time, then the scroll will seem to start from 
the right and scroll to the left instead of the first character popping up directly 
at the first position. 

The procedure that does the actual scrolling needs to be called every time the 
scroll needs to be updated. An OnTimer event (TTimer) suits good for that matter. 

4   procedure TForm1.Timer1Timer(Sender: TObject);
5   const
6     SCROLL_AREA = 10;
7   begin
8     // Gets the part of the scroll that should be displayed
9     Form1.Caption := Copy(ScrollText, ScrollPosition, SCROLL_AREA);
10  
11    // Increase scroll position to the next character
12    Inc(ScrollPosition);
13  
14    // Reset position when the scroll has reached it's end
15    if ScrollPosition >= Length(ScrollText) then
16      ScrollPosition := 0;
17  end;


The code is pretty self explaining together with it's comments. The constant 
SCROLL_AREA decides how many characters of the scroll should be displayed at once. 

Exactly the same code may be used to scroll text in an TEdit control instead, simply replace Form1.Caption with Edit1.Text (or what the name of the control is) instead. To make the title of the window that is viewed in the Start-menu toolbar to scroll, use Application.Title. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC