Available in the LEADTOOLS Imaging toolkit. |
FilePage Event Example for Access 2.0
This example shows how the FilePage event can be used to size and position a lead control when an image is loaded.
Sub Lead1_FilePage ()
Dim HeightFactor, WidthFactor ' Factors for aspect ratio
Dim HeightAllowed, WidthAllowed ' Maximum width and height
' Set the variables used for preserving the aspect ratio.
'Allow for a border of 1/8 of the form size.
'The units of measure do not matter, since we are calculating proportions.
HeightFactor = Me![LEAD1].Object.InfoHeight
WidthFactor = Me![LEAD1].Object.InfoWidth
HeightAllowed = Me.WindowHeight * 3 / 4
WidthAllowed = Me.WindowWidth * 3 / 4
'Center the LEAD control on the form, preserving the aspect ratio.
'Check to see if using the maximum width will make the image too tall.
'Set the dimensions based on the result.
If ((WidthAllowed * HeightFactor) / WidthFactor) < HeightAllowed Then
Me![LEAD1].Left = Me.WindowWidth / 8
Me![LEAD1].Width = WidthAllowed
Me![LEAD1].Height = (Me![LEAD1].Width * HeightFactor) / WidthFactor
Me![LEAD1].Top = (Me.WindowHeight - Me![LEAD1].Height) / 2
Else
Me![LEAD1].Top = Me.WindowHeight / 8
Me![LEAD1].Height = HeightAllowed
Me![LEAD1].Width = (Me![LEAD1].Height * WidthFactor) / HeightFactor
Me![LEAD1].Left = (Me.WindowWidth - Me![LEAD1].Width) / 2
End If
' Set the image display size to match the LEAD control.
Me![LEAD1].Object.AutoScroll = False
Me![LEAD1].Object.AutoRepaint = True
Me![LEAD1].Object.AutoSetRects = True
Me![LEAD1].Object. PaintSizeMode = PAINTSIZEMODE_FIT
End Sub