Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display a Tif picture in VB6

Status
Not open for further replies.

BBG

Programmer
Mar 18, 2002
7
0
0
DE
How can I simply display a Tif picture on a form in VB6, via VB6 code, components or Windows API?
Please note that a program that can view Tif files may or may not be on the user's PC - the only things that may be on the PC is the OS and any VB6 run time files or components. So, I am not sure if a object container(OLE) will work when there are no programs associated with a Tif file.
The user will either see the Tif either on the form in a picture control when the form opens, or need to click on a button on the form to open a window in order to view the Tif picture. That shouln't matter.

If not possible in VB6, then maybe I can use Shell to call another program delivered with the Windows OS, or some lightweight free-bee program that can be downloaded and that I can freely distribute with my application. Anyone know of one if the first part above isn't possible?

PS. The only thing that is needed here is to show a Tif picture - nothing else.

Thankyou for any help!
 
You can show a TIF on a VB form by putting it in a picture box control and setting the Picture property to the path where the TIF is. You will need to include the TIF and the PictureBox ocx in your installation in order to run it though.
 
Thank you very much for responding!

Have you already tried doing this successfully?

I cannot seem to load a Tif file into a picture box - I always get an error (unrecognized format) - I have tried several Tif files.
 
And, unfortunately, you won't be able to. The VB picturebox doesn't support TIFs. There is a commercial product, Extended Picturebox, which does. or you could have a look at the Wang/Kodak Imaging controls that come as part of Windows; these do support TIF (but they cannot be classed as the most straighforward or well-documented controls that I have encountered!)
 
I did test this out again and it works fine for me. I used a standard MS picture box(VB.PictureBox) and set the Picture property at design time to the .TIF file. I didn't use the enhanced Picture Box???
 
p.s. Maybe you could just save the .TIF as a .BMP and load into PictureBox control that way??
 
Well, I don't know how you are doing it. Don't just take my word for it; here is what the VB6 documentation has to say on the subject:

"A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files."

At design time, you have to select "All Files" in the Load Picture dialog before it will even show TIF files (i.e. 'All Picture Files' does not recognize TIF as an accepted format).

So you must have done something...
 
NipsMG:
Thanks. I downloaded this generous code but it is not working for Tiff files. I will try to inform the author to see if it can be fixed.
 
It's a lot simpler than you'd think, actually. All versions of Windows since NT 4.0 have (very good) imaging support built into them. You set a reference to the Kodak Image Edit Control ona Win2K box, or the Wang equivalent on an NT 4.0 box. Then you draw the control on the form and use the following code:
Private Sub Form_Load()
ImgEdit1.Image = <name of TIF file>
ImgEdit1.Display
End Sub

and, er, that's it.
There are 3 other imaging controls you can use: Scan, Admin and Thumbnail. Give these a go.

muesli
 
Having used them a lot, I think they are probably the simplest and easiest way to show TIF files. Once you get the hang of them they aren't too bad, honest!
 
Oh, I agree. Once you get used to them, they are fine - but, as I say, they really are not that well documented.
 
You people were right - and a great help!
I finally found out what you were talking about (should have read the suggestions closer).
The Kodak.img exe comes with a oca and ocx. Under Win 95 and NT it was Wangimg.exe. I found a sample application that was installed with Win 95 and Win Nt. I was concerned with the licensing and found at the top of the sample program:
&quot;Copyright (C) 1995 Wang - You have a royalty-free right to use, modify, reproduce and distribute
the Sample Application Files (and/or any modified version) in any way you find useful, provided that you agree that Wang has no warranty, obligations or liability for any Sample Application Files.&quot; Etc...

The sample app works like a charm and most menu points are coded (scan In, Rotate, Flip, etc, etc) and the proceedures have at least some comments.

Because the Kodakimg.exe is installed by default (extras) by all Windows OS, then the ablility to view Tiff files on any system via OLE control should work. But this is better than using an OLE control - you can create a form and do what you want with it!

Also, for those who have Crystal Reports you can use this as well to view Tiff files - Crystal Reports apparently doesn't need OLE to do this.

I hope others with the same problem find this site and suggestions. During my net searches I only found some Shareware and some great attempts from programmers to write code to do read images (but not successful with Tiff files).

This solves the problem and even more.

Once again thanks for all the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top