'對全局變量和API函數(shù)的通用聲明(API函數(shù)Sleep, BitBlt及其常參數(shù)SRCCOPY的聲明從略,可從API瀏覽器中復制、粘貼): Dim 1(4) As Boolean, i as Long, s As String, zt As Integer '實現(xiàn)圖片漸現(xiàn)漸隱的通用過程: Private Sub PicCpy(Optional strip As Integer=10, Optional delay As Integer=20) Dim plw As Integer, plh As Integer,p2 As Integer If 1(3)=True Then Picture1 = LoadPicture("c:\win98\安裝程序.bmp") Else Picture1=LoadPicture("") End If plw = Picturel.Width plh=Picturel.Height p2=0 Do While p2<= plw BitBlt Picture2.hDC,p2,0, strip, plh, Picture1.hDC,p2,0,SRCCOPY p2=p2 + strip Sleep delay DoEvents Loop'由于圖片寬度不一定是strip的整數(shù)倍,故下面再全圖復制一遍圖片: BitBlt Picture2.hDC,0,0,plw,plh,Picture1.hDC,0,0,SRCCOPY End Sub Private Sub Form_load() Label1.Font.Name="黑體" Image1.Top=0 Image1.Left=0 Picture2.Top=0 Picture2.Left=Screen.Width - Picthne2.Width s="產(chǎn)生縮放和隱現(xiàn)效果的文字" zt=5'zt為字體大小控制變量 i=0 'i為顯示文字時截取文字的字數(shù)變量 End Sub Private Sub Cmd_Click (Index As Integer) If 1(Index)=True Then 1(Index)=False Else 1(Idex) = True End If Select Case Index Case 0 '激活timer1的timer過程 Timer1.Enabled=True Timer1.Interval=50 ...... 'Case1, 2與上述類似,分別激活timer2, timer3的timer過程 Case 3 '調用圖片復制過程Piccpy PiCpy 10, 50 Case 4'結束程序運行 Unload Me End End Select End Sub Private Sub Timer1_Timer() '實現(xiàn)文字縮放的過程 If 1(0)=Trun Then zt=zt<+5 Else Zt=Zt-5 Else If If zt>50 or zt<=5 Then Timer1.Enabled=False End If With Label1 .Font.Size=zt .Left=(Form1.Width - Lable1.Width) /2 .Top=(Form1.Height - Label1.Height)/2 End With Label1.Caption=s End Sub Private Sub Timer2_Timer() '實現(xiàn)圖片縮放的過程 If 1(1)=True Then '使圖片放大 Image1.Width=Image1.Width+Form1.Width/10 Image1.Height=Image1.Height+Form1.Height/10 Else '使圖片縮小 Image1.Width=Image1.Width - Form1.Width/10 Image1.Height=Image1.Height - Form1.Height/10 End If If (Image1.Width >=Form1.Width/2) or(Image1.Width <=Form1.Width/10) Then Timer2.Enabled=False End If Image1=LoadPicture("c:\win98\安裝程序.bmp") End Sub Private Sub Timer3.Timer() Label1.Font.Size = 30 If 1(2)=True Then i=i+l Else i=i一1 End If If i >=Len(s) on i<1 Then Timer3.Enabled=False End If If i >=0 Then Label1.Caption=Left$(s,i) End If End Sub |