Ever thought about designing your own graphical browser? In fact, this is not difficult at all, we can easily use VB programming to achieve it.
The design process of the graphical browser is as follows:
1. Start VB, create a new standard project file, and on the form Form1, change the Caption of Form1 = "Graphic Browser".
2. Add the drive, folder and file controls to the form from the toolbox. The drive's Name is Diver1, the folder's Name is Dir1, and the file's Name is File1, and adjust the appropriate positions.
3. Add the PictureBox control to the form from the toolbox. The Name of the PictureBox is Picture1, and adjust the appropriate position, height and width.
4. From the toolbox, add the CommandButton control to the form. The Name of the CommandButton is Command1, and adjust the appropriate position, height and width.
5. Double-click the mouse in the blank space of the form to pop up the code editing window and enter the following code:
PRivateSubForm_Load()
'Set the drive and directory where the application is located as the current drive and directory
'App is the current application object
Drive1.Drive=App.Path
Dir1.Path=App.Path
File1.Pattern="*.bmp;*.ico;*.wmf"
EndSub
6. Double-click the driver control on the form to bring up the code editing window and enter the following code:
PrivateSubDrive1_Change()
'When the selected drive changes, update the contents in the directory list box; when the directory changes, trigger the Change event of the directory list box
Dir1.Path=Drive1.Drive
EndSub
7. Double-click the mouse on the folder control of the form to pop up the code editing window, enter the following code:
PrivateSubDir1_Change()
'When the directory changes, update the contents of the file list box
File1.Path=Dir1.Path
EndSub
8. Double-click the mouse on the file control of the form to pop up the code editing window, enter the following code:
PrivateSubFile1_Click()
'Root directory, the last character in the path is a backslash "/", such as: C:/
'When it is a non-root directory, the last character in the path is not a backslash "/"
'To get the complete file name, you should add a backslash "/" at the end of the path
IfRight(File1.Path,1)〈〉"/"Then
'When it is a non-root directory, add a backslash "/" at the end of the path
tempstring=File1.Path&&"/"&&File1.FileName
Else
tempstring=File1.Path&&"/"&&File1.FileName
EndIf
'Load selected files
Form1.Picture1.Picture=LoadPicture(tempstring)
EndSub
9. Double-click the "Close" control of the form to bring up the code editing window and enter the following code:
PrivateSubCommand1_Click()
UnloadMe
End
EndSub
Save the file and run it, and your own graphical browser is ready. ->