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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image control - resize box dynamically?

Status
Not open for further replies.

ChrisWest99

Technical User
Mar 28, 2003
8
US
Hello,

I'm working with images on a report. I need the image to be shown normal size.
I've linked the control to a table that contains the UNC path to the image (MS KB#210100)
But the Clip, Stretch and Zoom options do not do what I need.

When the report executes OnFormat, it needs to find the picture, determine the size of the image, then display the image in the report at the determined size. Then do the whole process over for the next record. If there is no image UNC in the table, it displays a 1x1 pixel image.

Can the image control on the report be dynamically resized as I've described?

Could the code posted here be modified to work on a report?

Any insight or ideas arfe appreciated. I've been trying various VB coding but can't seem to find the right mix.

Thanks,
Chris
 
Hi,
I haven't experimented with this, but an image control have "Can Grow" and "Can Shrink" properties. Can you try setting both to YES, and see what happens then? HTH, [pc2]
Randy Smith
California Teachers Association
 
Hi Randy,

The Shrink/Grow property works if the Image Control is on a Form. The option is not available for Image Controls on Reports. :-(

Thanks,
Chris
 
Code I'm working with. Anyone see what I have missed?

Thanks,
Chris
=================
------------Begin Code ----------------------
Option Compare Database
---------------------------

Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.txtImageName
Me.ImageFrame.Picture = strImagePath
Call ImgSize(nWidth, nHeight)
Me.ImageFrame.Width = nWidth
Me.ImageFrame.Height = nHeight

Exit Function

PictureNotAvailable:
strImagePath = "C:\Databases\NoImageTiny.jpg"
Me.ImageFrame.Picture = strImagePath

End Function
---------------------------

Private Sub ImgSize(nWidth, nHeight)
strImagePath = Me.txtImageName
sImageFile = strImagePath + "\" + Text3.Text + _
format(yCount, "00") + ".jpg"
Open sImageFile For Binary Access Read As #1

Do While Not EOF(1) ' Loop until end of file.
yByte = Input(1, #1)
If yByte = Chr(255) Then
yByte = Input(1, #1)
If yByte = Chr(192) Or yByte = Chr(194) Then
'skip these bytes
yByte = Input(1, #1) 'first length byte
yByte = Input(1, #1) 'second length byte
yByte = Input(1, #1) 'type byte

'these are the bytes you want
yByte = Input(1, #1) ' msb of height
nHeight = Asc(yByte)
yByte = Input(1, #1) ' lsb of height
nHeight = nHeight * 256 + Asc(yByte)
yByte = Input(1, #1) ' msb of width
nWidth = Asc(yByte)
yByte = Input(1, #1) ' lsb of width
nWidth = nWidth * 256 + Asc(yByte)
Exit Do
End If
End If
Loop
Close #1

End Sub
---------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

End Sub
------------End Code ----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top