Adjust size of field to graphic

Hi Clifton,
I am trying to use a TB field to display a series of pictures of different sizes. I hoped that setting width and height to auto with pgStyleObject might do it but I guess this if for text only. I need to adapt the size of the field to the size of the picture but also impose maximum width and height.
In my VS VB.NET version it was relatively easy. I first got the dimensions of the picture and then displayed the picture in a picturebox object. Here's the code I used (if that's any help):
Can you help please?
John
I am trying to use a TB field to display a series of pictures of different sizes. I hoped that setting width and height to auto with pgStyleObject might do it but I guess this if for text only. I need to adapt the size of the field to the size of the picture but also impose maximum width and height.
In my VS VB.NET version it was relatively easy. I first got the dimensions of the picture and then displayed the picture in a picturebox object. Here's the code I used (if that's any help):
- Code: Select all
'GET SIZE OF IMAGE & ADAPT IT TO THE SPACE AVAILABLE (making it as big as possible).
'CHECK THAT FILE IS LOADABLE
Try
objImage = System.Drawing.Image.FromFile(FilesHome & NameOfFile)
Catch ex As Exception
'Error ...
ShowRequest(GetText(129), "&OK")
Me.Cursor = Cursors.Default
If NewFolder = True Then
DeleteExercise(FilesHome)
End If
Exit Sub '============>
End Try
objImage = System.Drawing.Image.FromFile(FilesHome & NameOfFile)
'CREATE SIZE VARIABLES
Dim Vwidth As Integer = objImage.Width
Dim Vheight As Integer = objImage.Height
objImage.Dispose()
Dim VWidth2 As Integer
Dim VHeight2 As Integer
Dim Vunit As Decimal
'RESIZE
If Vwidth > Vheight Then
Vunit = 455 / Vwidth
VWidth2 = 455
VHeight2 = Vheight * Vunit
'REVERSE IF IMAGE IS TOO HIGH
If VHeight2 > 600 Then
VHeight2 = 600
Vunit = 600 / Vheight
VWidth2 = Vwidth * Vunit
End If
Else
VHeight2 = 600
Vunit = 600 / Vheight
VWidth2 = Vwidth * Vunit
'REVERSE IF IMAGE IS TOO WIDE
If VWidth2 > 455 Then
Vunit = 455 / Vwidth
VWidth2 = 455
VHeight2 = Vheight * Vunit
End If
End If
PictureBox1.Width = VWidth2
PictureBox1.Height = VHeight2
PictureBox1.ImageLocation = (FilesHome & NameOfFile)
PictureBox1.Load()
'Fill Pdetails
Total = Total + 1
Pdetails(Total - 1, 0) = NameOfFile
Pdetails(Total - 1, 1) = VWidth2 & "," & VHeight2
Can you help please?
John