{Implement dynamic subtitle} in Delphi}

zhaozj2021-02-17  70

{If you have used "Jinshan Words" or "Oriental Express", you will be interested in the scrolling subtitles in its "About" window, in fact, using the Timer control in Delphi can easily implement this feature.

First, design ideas

First put a panel control on the form and place the text you want to display in the Panel control, and then through the Timer control, you can constantly change the position of the Panel control in a certain interval. The effect of the scrolling subtitles can be achieved.

Second, implementation

1. Create a new form to set its properties as follows:

Name: frMabout1

AutoScroll: false

2. Place a panel control on the form, the default name is Panel1, set its properties as follows:

Bevelouter: Bvnone

CAPTION: (set to empty)

Adjust the height and width of Panel1 so that it is a vertical strip shape, which is highly regarded as if the content is displayed (can be greater than the height of the form).

3. Place the Label control on the Panel1 to display text, of course, you can also place an Image control above to display pictures, but the size of the picture is not too big, otherwise it will affect the display.

4. Place a Timer Control on the form whose default name is Timer1, set its interval property 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;

{Judge Panel1 to move to the top of the form, if not, move the position of a pixel point upwards; if it is, move Panel1 to the lowermost end of the form, loop display subtitle}

5. Place a Button control on the form, set its CAPTION attribute to "OK", and enter the following code in the onclick event:

Close; {close form}

Third, improvement analysis

The above is a simple rolling subtitle implementation process, but there is still a place to improve: If the form uses pictures as a background, the Panel control will cover some background pattern. In fact, we must solve this problem, we can completely do not use the Panel control, but directly on the form, and set the Label control's Transparent (transparent) property value to True, then directly control these Label controls directly through the Timer control Mobile. Limited to the space, the author is no longer specified.

转载请注明原文地址:https://www.9cbs.com/read-31256.html

New Post(0)