----The author occasionally read an article in "Computer World" about implementing character fade-out and fade-in in VISUALFOXPRO. Inspired by this, the author referred to the original article and wrote a similar character fade-out and fade-in using Visual Basic 4.0. program to illustrate the commonalities of Microsoft's visual development tools: the same or similar graphical user interface (GUI), object-oriented and event-driven features, the same or similar functions, etc. This feature allows program developers and designers to learn from applications developed using different Microsoft visualization tools and carry out convenient transplantation, shortening the development cycle. At the same time, this can play a role in learning computer language.
----The fade-in and fade-out function of characters can be accomplished by continuously changing the foreground of the label (LABEL) control. Changes in the control's foreground,
It can be set using the foreground property of the label control at design time, or it can be achieved in the program by assigning different color values to the foreground property. Color is provided by the RGB function (VisualFoxpro also has this function). The interrupt generated by the timer control is used to continuously change the RGB parameter value, so the foreground of the character can be changed accordingly, achieving the purpose of fading in and out.
----The program written below using Visual Basic 4.0 completes two functions: (1) Fade in and out of characters, and there are 256*256*256 color changes. Here only the change from gray to red is selected;
(2) The characters go from small to large when fading out, and from large to small when fading in. In addition, the implementation process of this program can be completely and easily transplanted to visual languages such as VisualC and Visualjava.
----1. Start VisualBasic4.0 and automatically generate a form, the default is FORM1.
----2. Set the properties of the form as follows:
NAME: DEMO
CAPTION: VB implements character fade-in and fade-out
BACKCOLOR: &H00C0C0C0, that is, the background is gray
----3. Define the following form variables in the form DEMO, that is, define the color parameters R, G, and B in the General-declaration process.
DimrAsInteger
DimgAsInteger
DinbAsInteger
----4. Set the initial value of the character color during the Form-load process, that is, gray
color:
PrivateSubForm_Load()
r=192
g=192
b=192
EndSub
----5. Add a label to the form DEMO and set its properties as follows:
NAME:LABEL1
CAPTION: Harbin SDIC Bond Trading System
AUTOSIZE: TRUE, used to achieve character scaling
BACKSTYLE: 0-TRANSPARENT, i.e. transparent
FONT: The font is official script, and the size is selected as 8
----6. Add a timer control to the form to complete the fade-out function. The settings are as follows:
NAME: OUTTIMER
INTERVAL: 50, which means it interrupts once every second and changes color once.
----7. Add another timer to complete the fade-in function:
NAME: INTIMER
INTERVAL: 50
----8. Add the following code to the TIMER process of OUTTIMER:
PrivateSubOuttimer_Timer()
Ifr<255Then
r=r 1
Else
r=255
EndIf
Ifg>3Then
g=g-3
Else:g=0
EndIf
Ifb>3Then
b=b-3
Else:b=0
EndIf
Label1.FontSize=Label1.FontSize 0.75
Label1.ForeColor=RGB(r,g,b)
IfLabel1.FontSize>=72Then
Outtimer.Enabled=False
Intimer.Enabled=True
EndIf
EndSub
----9. Add the following code to INTIMER:
PrivateSubIntimer_Timer()
Ifr>192Then
r=r-1
Else
r=192
EndIf
Ifg<192Then
g=g 3
Else:g=192
EndIf
Ifb<192Then
b=b 3
Else:b=192
EndIf
Label1.FontSize=Label1.FontSize-0.75
Label1.ForeColor=RGB(r,g,b)
IfLabel1.FontSize<=8Then
Intimer.Enabled=False
Outtimer.Enabled=True
EndIf
EndSub
----After completing the above steps, press the run button, you can see the words "Harbin SDIC Securities Trading System" displayed in the form from small to large, from shallow to deep; when the font reaches When the specified size is reached, it gradually disappears into the form to realize the fade-in and fade-out function.
->