新建一个工程, 添加 TEXT1.TEXT , 按钮 , IMAGE 控件.
按钮的单击代码,我只说大概:
IF TEXT1.TEXT = "自己的照片" THEN
image.picture=loadpicture("d:\photo\" + TEXT1.TEXT + ".JPG")
然后在添加个按钮, 名字为: 下一张
单击代码: image.picture=loadpicture("d:\photo\自己的照片" + "1" + ".JPG")
BitBlt
StretchBlt
添加一个列表框名为list1、一个CommonDialog控件名为CommonDialog1、一个图片框名为Picture1、两个按钮(command1,caption属性为添加;command2,caption属性为删除)。附图。可根据需要调整位置,还可以将picture1的AutoSize属性设为Ture,以根据图片大小调整图片框大小。添加以下代码:
Option Explicit
Dim Address As String
Dim filename As String
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If CommonDialog1.filename <> "" Then List1.AddItem CommonDialog1.filename
End Sub
Private Sub Command2_Click()
If List1.ListIndex <> -1 Then
List1.RemoveItem List1.ListIndex
Else
MsgBox "没有选择要删除的项目", vbCritical + vbApplicationModal, "错误"
End If
End Sub
Private Sub Form_Load()
CommonDialog1.InitDir = App.Path
CommonDialog1.DialogTitle = "选择图片"
CommonDialog1.Filter = "图片(*.bmp*.jpg*.gif)|*.bmp*.jpg*.gif"
filename = App.Path & "\" & "Add.INI"
If Dir(filename) = "" Then Exit Sub
Open filename For Input As #1
Do While Not EOF(1)
Line Input #1, Address
List1.AddItem Address
Loop
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open filename For Output As #1
Dim i As Integer
For i = 0 To List1.ListCount
Print #1, List1.List(i)
Next
Close #1
End Sub
Private Sub List1_Click()
If List1.ListIndex <> -1 Then
Picture1.Picture = LoadPicture(List1.Text)
Else
MsgBox "没有要显示的图片", vbApplicationModal + vbCritical, "错误"
End If
End Sub
Picture控件 和Timer 控件各一个,其中Picture控件用来加载图片Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static n As Integer
If n = 10 Then End
n = n + 1
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)