If you have used "Kingsoft PowerWord" or "Orient Express", you will definitely be interested in the rolling subtitles in their "About" window. In fact, this function can be easily realized using the Timer control in Delphi.
1. Design ideas
First, place a Panel control on the form and place the text that needs to be displayed in the Panel control. Then, through the Timer control, the position of the Panel control can be continuously changed within a certain interval to achieve the effect of rolling subtitles.
2. Implementation method
1. Create a new form and set its properties as follows:
Name:frmAbout1
AutoScroll:False
2. Place a Panel control on the form, its default name is Panel1, and set its properties as follows:
BevelOuter:bvNone
Caption: (set to empty)
Adjust the height and width of Panel1 to make it a vertical strip. The height depends on the content to be displayed (it can be greater than the height of the form).
3. Place a Label control on Panel1 to display text. Of course, you can also place an Image control on it to display pictures, but the size of the picture should not be too large, otherwise it will affect the display effect.
4. Place a Timer control on the form, its default name is Timer1, set its Interval property value to 50, and enter the following code in its OnTimer event:
if Panel1.top>-Panel1.height then
Panel1.top:=Panel1.top-1
else
Panel1.top:=frmAbout1.height-35;
{Determine whether Panel1 has moved to the top of the form. If not, move it up one pixel; if so, move Panel1 to the bottom of the form and display the subtitles in a loop}
5. Place a Button control on the form, set its Caption property to "OK", and enter the following code in the OnClick event:
close;{Close the form}
3. Improve analysis
The above is a simple implementation process of rolling subtitles, but there is still one area that needs further improvement: if the form uses a picture as the background, the Panel control will block part of the background pattern. In fact, to solve this problem, we can not use the Panel control at all, but directly place the Label control on the form, set the Transparent property value of the Label control to True, and then directly control these Label controls through the Timer control. of movement. Due to space limitations, the author will not describe it in detail here.