VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



I was working on an application that required the display of pictures. There was no way of predicti

by Marc Dalcourt (1 Submission)
Category: Graphics
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 14th June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

I was working on an application that required the display of pictures. There was no way of predicting or specifying the sizes and

Rate I was working on an application that required the display of pictures. There was no way of predicti



Private Sub cmdPicture_Click()

    Dim str As String, str2 As String
    Dim strDrive As String
    
    On Error GoTo Oops
    
         'Get a picture.
    cdlPicture.ShowOpen
    Image1 = LoadPicture(cdlPicture.FileName)
    
         'Resize the picture.
    Call sResizePicture
    
        'If the report was saved anywhere other
        'than the default directory (App.Path),
        'the whole application will look for
        'its support in that other directory.
        'The next few lines ensure that we are
        'in the correct path.
    str2 = App.Path
    strDrive = Mid$(App.Path, 1, 1)
    str = CurDir
    
    If str <> str2 Then
        ChDrive strDrive
        ChDir str2
        str = CurDir
    End If
    
    Exit Sub
    
Oops:
    MsgBox Err.Description, vbExclamation
    
End Sub

Private Sub sResizePicture()
    
    Dim dblRatio As Double
    
    If Image1.Picture.Height > Image1.Picture.Width Then
        dblRatio = Image1.Picture.Width / Image1.Picture.Height
        Image1.Height = 2160    'Two inches
        Image1.Width = 2160 * dblRatio   'Two inches
    ElseIf Image1.Picture.Width > Image1.Picture.Height Then
        dblRatio = Image1.Picture.Height / Image1.Picture.Width
        Image1.Height = 2160 * dblRatio    'Two inches
        Image1.Width = 2160   'Two inches
    End If
    
    Image1.Stretch = True

End Sub

Download this snippet    Add to My Saved Code

I was working on an application that required the display of pictures. There was no way of predicti Comments

No comments have been posted about I was working on an application that required the display of pictures. There was no way of predicti. Why not be the first to post a comment about I was working on an application that required the display of pictures. There was no way of predicti.

Post your comment

Subject:
Message:
0/1000 characters