程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 用VB5制作家庭影集

用VB5制作家庭影集

編輯:VB綜合教程

  你想擁有自己的電子家庭影集嗎?其實用VB就能實現。方法如下:

  准備:家庭普通照片經掃描後儲存。

  構想:照片一張接一張出現在屏幕中間,出現時的方式采取動態切換,上方一行標題從左向右移過,標題與照片的背景色隨機變化。

  關鍵:調用Bitblt Windows API函數實現照片的動態切換。

  內容:工程由Forml和modluel構成。

  FORML中的內容如下:

  

Comst bmpfilemax=11 照片數目常量
Const bmpfile(bmpfilemax)As String照片的文件組
Dim brawbmpmode(bmpfilemax)As in-teger 照片的切換方式
Dim bmpnum,mouvstep,xmax,ymax,endmax,lleft,r,n ,As Integer 照片的序號,步進參數
Dim kxy As Single x y方向的比例
Private Sub Exit_Click( )
End
Ene Sub
Private Sub Form_Load( )
Labell.Lert=0
Labell.Caption="Family Album"
Picturel.AutoSize=True
Picturel,Visible=False
Bmpfile(0)=App,path+"  sonl.jpg"
Bmpfile(1)=App.Path+"  mom_sonl.jpg"
Bmpfile(2)=App.Path+" daddy_son.jpg"
Bmpfile(3)=App.path+" yu99yantai.jpg"
Bmpfile(4)=App.Path+" yu98singap2.jpg"
Bmpfile(5)=App.Path+" yu98singapore.jpg"
Bmpfile(6)=App.Path+" mom_son2.jpg"
Bmpfile(7)=App.Path+" yu99yan2.jpg"
Bmpfile(8)=App.Path+" fami_ly.jpg"
Bmpfile(9)=App.Path+" fan_yantai.jpg"
Bmpfile(10)=App.Path+" yu99yan3.jpg"
Drawbmpmode(bmpnum) =1+int (Rnd()*4)
Movestep=0 步進參數
Xmax=Forml.scaleWidth/
Ymax=Forml.scaleHeight/
Kxy=ymax/xmax
Picture1.picture=LoadPicture(bmpfile(bmpnum))
Timerl.Interval=30
End Sub 
Private Sub Timer1_Timer()
M=Forml.scaleWidth/_Pic_turel.width/照片顯示結束時的X方向居中定位
N=Forml.scaleHeight/_Pic_turel.Height/照片顯示結束時的Y方向居中定位
HDestDC=Forml.Hdc
HsrcDC=picture1.Hdc
Drawflag=drawbmpmode(bmpnum)照片顯示時的切換方式
Select Case drawflag
Case1 切換方式為從左右向中間進行
Time Interval=30
Endmax=xmax
W=movestep
H=picture1,Height
I=BitBlt(hDestDC,0+m,0+n,w,h,hSrcDC,0,0SRCCORY)
X1=Picture,width_movestep
I=BitBlt(hDestDC,X1+m,0+n,w,h,hSrcDC,X1,0,SRCCOPY)

  Case2切換方式為從中間向四周擴散進行

  

Timer1.Interval=30
Endmax=xmax
X1=xmax_movestep
W=movestep*2
Y1=cint(ymax-movestep*kxy)
H=cint(2*movestep)
I=BitBlt(hDestDC,X1+m,Y1+n,w,h,hSrcDC,X1,Y1,SRCCOPY)
Case3切換方式為柵欄翻轉進行
Timer1.Interval=200
Ednmax=Cint(2*xmax/10)
Tempi=Cint(2*xmax/10)
W=movestep
H=Picture1.ScaleHeight
For ij=0 TO 9
I=BitBlt(hDestDC,tempi*ij+m,0+n,w,h,hSrcDC,tempi*ij,0,SRCCOPY)
Next ij
Case4切換方式為從左向右進行
Timer1.Interval=30
Endmax=xmax
W=movestep*2
H=Forml.ScaleHeight
I=BitBlt(hDestDC,0=m,0+n,w,h,hSrcDC,X1,Y1,SRCCOPY)
Ends Select
Forml.Refresh
Movestep=movestep+4
Labell.left=movestep
Ifmovestep>endmax+60Then
Bmpnum=bmpnum+1
Ifbmpnum>bmpfilemax then
Bmpnum=0
End IF 
Cls
Movestep=0
Picture1.Picture=LoadPic_1+int(Rnd()*4)
Backcolor=QBColor(Rnd*15)
Labell.ForeClolr=QBColor(Rnd*10)
If backcolor=Labell.ForeColor Then
Labell.forecolor=vbBlack
End if
Labell.Caption=family album"
Labell.top=picturel.top
End if 
End sub

  Modluel中的內容如下:

  

Option explicit
Public comst SRCCOPY=&HCC0020(DWORD)dest=source
Declare Function BitBlt Lib"gdi32"(byval hDestDCAs_
Long,byval x as long,byval y as long ,byval n width_
Byval xsrc as long,byval ysre as long ,byval dwrop as long)as long

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved