In lesson 16, we have created an audio player. Now, with some modifications, we will transform the audio player into a picture viewer. This player will be created in such a way that it could search for all types of graphics your drives and play them.
Similar to the previous project, in this project, you need to insert a ComboBox, a DriveListBox, a DirListBox, a TextBox and a FileListBox into your form. I Shall brieflyexplain again the function of each of the above controls.
- ComboBox- to display and enable selection of different type of files.
- DriveListBox- to allow selection selection of different drives available on your PC.
- DirListBox - To display directories
- TextBox - To display selected files
- FileListBox- To display files that are available
Relevant codes must be written to coordinate all the above controls so that the application can work properly. The program should flow in the following logical way:
Step 1: User choose the type of files he wants to play.
Step2:User selects the drive that might contains the relevant graphic files.
Step 3:User looks into directories and subdirectories for the files specified in step1. The files should be displayed in the FileListBox.
Step 4: User selects the files from the FileListBox and click the Show button.
Step 5: User click on Exit button to end the application.
¡¡
The Interface
The Code
Private Sub Form_Load()
Left = (Screen.Width - Width) \ 2
Top = (Screen.Height - Height) \ 2
Combo1.Text = "All graphic files"
Combo1.AddItem "All graphic files"
Combo1.AddItem "All files"
End Sub
¡¡
If ListIndex = 0 Then
File1.Pattern = ("*.bmp;*.wmf;*.jpg;*.gif")
Else
Fiel1.Pattern = ("*.*")
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File1.Pattern = ("*.bmp;*.wmf;*.jpg;*.gif")
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Exit_Click()
End
End Sub
Private Sub File1_Click()
If Combo1.ListIndex = 0 Then
File1.Pattern = ("*.bmp;*.wmf;*.jpg;*.gif")
Else
File1.Pattern = ("*.*")
End If
If Right(File1.Path, 1) <> "\" Then
filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
Text1.Text = filenam
End Sub
Private Sub play_Click()
MMPlayer.FileName = Text1.Text
End Sub
Private Sub show_Click()
If Right(File1.Path, 1) <> "\" Then
filenam = File1.Path + "\" + File1.FileName
Else
filenam = File1.Path + File1.FileName
End If
picture1.Picture = LoadPicture(filenam)
End Sub
No comments:
Post a Comment