Picture Viewer

Hi
I am just learning VB and I am following tutorials, I have just created a picture viewer using the code as below

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
 

Private Sub Combo1_Change()
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


The program works but the picture files are to big for my picture box is there any thing I can do to make the images fit inside my picture box.
Regards
Planner
planner1234Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kriyengCommented:
hi planner!

You should use image control and not picture control.
In image control you have the stretch option to fit the image in your image control (true=fit image, false=not fit). You have other properties like constrain proportions or not.

The usage is similar than picture box.

bye!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
If you want to maintain the aspect ratio then load the picture into a stdpicture object and then use the PictureBoxes PaintPicture() method:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20060075.html
planner1234Author Commented:
Hi kriyeng
I thought this that would be a solution to the problem I was having, but do I need to alter my code to reflect using an image box instead of a picture box.

probably alter the line that is
picture1.Picture = LoadPicture(filename) maybe ?
Regards
Planner

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Just substitute the Image control name for the PictureBox name:

    Image1.Picture = LoadPicture("c:\someImage.bmp")
kriyengCommented:
hi planner!

thx for points!

yes, the usage is quite similar than picture control.

bye.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.