Library tutorials & articles
Making a picture browser in VB 6
- Introduction
- Getting Started
- Adding the Controls
- Linking the controls
- The Picture Preview
Getting Started
Our application will be titled ‘Picture Browser’. At present, keeping our application to a single form will be a better approach, as it will keep things simple. If you are following some books or web-sites etc, you must have seen the term MDI and SDI, they respectively mean, multiple document interface and single document interface. In an MDI application, several forms can be loaded, but this application of ours, will have a single interface, a requirement of the scope.
The controls we will use are going to be Picture Box, Drive List Box, Directory List Box and File List Box, that’s it! Simple isn’t it? And its not problematical to figure out what these controls are for. The picture box will display the picture and the rest will give you access to the location of the file you want to appear in the picture box.
Now, consider a hypothetical path: [c:\] [images\] [rose.jpg] these
three parts (the square brackets) are important thing to understand, they represent
the complete path to the image. The first is the drive letter; we will use the
drive list control to get this part. Second is the name of the directory, in
this example its ‘images’ but keep in mind that it could have sub-directories
too, say for example, “images\flowers\roses” can be the directory structure where
you store the pictures of roses in your computer, for this part, the drive list
control will be used. The last part is the file name and that, as you must have
guessed, will be done by using the file list control.
So, having sufficient knowledge about the controls, (the building blocks of your application) we can head towards placing them at right positions on the form.First of all, open the Visual Basic 6.0, select the ‘Standard Exe” as the new project type.
Related articles
Related discussion
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
-
VB6 compatability from XP to Vista
by bronx (1 replies)
I am really interested in your project. would you please mail the project to me.
Thanking in anticipation.
Anand Dutta
aldutt01@gmail.com
aldutt01@yahoo.com
I am but a newbie to VB but I think you can only do text on dialog boxes.... if it were a picture on the form then I would do it the same as viewing it - only small....
I have a few problem with my VB and I'm hoping someone can help me.
I want to add a Preview in a dlg box when a user is selecting an image. I have been searching for a code but it's so hard.
Another question is, I want to add a form page with 3 panels, 1 on the left side and 2 on the right (1 is above one another). Can someone help me with that?
Ellos
i am making a picture view i have a list of file, o n a the F drive i need to change the driver letter?
i also need to be able to view the pictures?
Confus
i've put up www.combatgold1.co.uk/VB for all my VB projects (with source files) - its not finished yet, but when i have time i'll finish it off
Look at my program - I've done all you want and more on there. I'll send you the project files if you want?
You cant call a form image because it's a reserved name.
VB will think you mean an image and not your form.
It's recommended to give a form a name which begins with 'frm' and then then name.
Hi
I have carried out this tutorial and it was xtremely helpful. It worked perfectly on its own.
When I connected it to a command button on my application using the code
Private Sub cmdAddLogo_Click()
Image.Show
End Sub
Image being the name I gave to the form
I got this error runtime error 438 Object doesnt support this property or method
Can u help with this
thanx a mil
Sabrina
I am only an amature so i can only give u so much advice............there is a dialog, like the open and save on.....create a button and insert the code to launch the open thingy..........you can fine the code if you create a project with the wizard........it will create the code for you....all you have to do is copy and paste......................................................enjoy!!
All my software that is complete is avalible on my home page:
http://mysite.freeserve.com/CombatGold1/index.html
Click on the Files tab.
If your using FM20 in your Api, only the people who have microsoft office will be able to use it.
The fm20 dll and ocx familly belong to microsoft and you can't distibute it.
The only advise that Microsoft give about FM20 is avoid it.
smartfx
im making a picture browser, how can you combine the save and open functions in one form (with different form name?)
You will find you might get a problem if you browse your 'net cache - some of the files in there may not be valid image files.
This often causes vb to hang.
Look at my program - I've done all you want and more on there. I'll send you the project files if you want?
I've finished my NEW version of Picture Browser.
Can we send attachments?
Finished my second picture browser. Can we send attachments?
I'm making a new version now - It's goinging good so far!
but yes... by using the "IMAGE" ctrl you make it use up less resources in your application. the other thing is.. if you ever want to use something as a container... DONT BE the fool that thinks their cool like a tool and use the Picturebox control... use frames without the BorderStyle... pictureboxes are like politicians... the less you have the better!
[3]
There is a better control to use!
There is a better control to use!
Instead of using a PictureBox, use the "Image" control. Call the image control ' Picture1 ' so you don't have to alter the code you have already put.
With that you can strecth images to the full size.
To use a check box to strech the picture, Insert a check box and:
Give it a name of ' chkStrech '
Put the caption as ' &Strech image to full size '
Insert this code:
Private Sub chkStrech_Click()
If chkStrech.Value = Checked Then Picture1.Strech = True
If chkStrech.Value = Unchecked Then Picture1.Strech = False
End Sub
[/3]
dsdsdsdsd
zxzxzx [arial] [/arial]
To answer your Question:
Yes you can restrict file types.
Add the following to the code secment of the form:
Private Sub Form_Load()
File1.Pattern = ".jpg;.bmp;*.gif"
End Sub
If you used the image control as suggested set the stretch property to TRUE as suggested and you're done.
BTW thanks for this little article saved me the time to think about how to create a browser.
Would be nice is MS would make the browser control available they use for word when inserting a picture, as that is what I was realy after, if anyone knows where to get this control or what the name is drop me a line please.
[2]
I've done alot now. To see an example of Picture Browser open my home page and click downloads.
You do not need to be a member of my home page to download this.
[/2]
[2]
I've been experimenting and found an even better control!
If you have it, add a component called ' Microsoft Forms 2.0 '
Use the Image control from that - you can change the position, zoom and strech. It's wicked!
Just remember to call it ' Picture1 ' to save time on coding again.
[/2]
[2]
There is a better control to use!
Instead of using a PictureBox, use the "Image" control. Call the image control ' Picture1 ' so you don't have to alter the code you have already put.
With that you can strecth images to the full size.
To use a check box to strech the picture, Insert a check box and:
Give it a name of ' chkStrech '
Put the caption as ' &Strech image to full size '
Insert this code:
Private Sub chkStrech_Click()
If chkStrech.Value = Checked Then Picture1.Stretch = True
If chkStrech.Value = Unchecked Then Picture1.Stretch = False
End Sub
[2]
[3]
There is a better control to use!
There is a better control to use!
Instead of using a PictureBox, use the "Image" control. Call the image control ' Picture1 ' so you don't have to alter the code you have already put.
With that you can strecth images to the full size.
To use a check box to strech the picture, Insert a check box and:
Give it a name of ' chkStrech '
Put the caption as ' &Strech image to full size '
Insert this code:
Private Sub chkStrech_Click()
If chkStrech.Value = Checked Then Picture1.Strech = True
If chkStrech.Value = Unchecked Then Picture1.Strech = False
End Sub
[/3]
Hi,
This tutorial is awesome :P
Is there a way to make that the file viewer shows only pictures (.jpg .gif .bmp...) ?
And, is there a way to make it show ALL the picture ? ( stretch it to fit the window )
thanks
This thread is for discussions of Making a picture browser in VB 6.