Stretching the Image on MDI Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahesh123
    New Member
    • Oct 2007
    • 64

    Stretching the Image on MDI Form

    Hi Folks,

    I Want regarding the stretching image on the MDI Form?

    I have one MDI Form and there is a image on that form? so that i want to stretch the image on the form according to the screen resoluation? these are the requriments i have? so please help me urgently.

    Thanks & Regards
    ---------------------------
    Mahesh
  • Bum
    New Member
    • Jan 2008
    • 19

    #2
    Hi Mahesh,

    Look at

    Screen.TwipsPer PixelX
    Screen.TwipsPer PixelY

    You get the size of your screen this way.

    if you want, you can do below, add three pictureboxes to mdiform adn make them the same size as the mdiform like

    picture1.height = mdiform1.height
    picture1.width= mdiform1.width

    [CODE=vb]
    Public Sub Setup_Image(Fil eName)

    'picture1 is the main interface
    'picture2 holds the original picture
    'picture3 holds the resized image and transfers it to picture1

    'everyones in twips
    Picture1.ScaleM ode = 3
    Picture2.ScaleM ode = 3
    Picture3.ScaleM ode = 3
    Me.ScaleMode = 3

    'assign our pic
    Picture2.Pictur e = LoadPicture(Fil eName)

    HW = 600 'height/width 'size of our square
    Picture1.Width = HW
    Picture1.Height = HW
    Picture3.Width = HW
    Picture3.Height = HW

    'find out if the pic is tall or fat then scale to fit in box, then center
    MyWidth = Picture2.Pictur e.Width
    MyHeight = Picture2.Pictur e.Height

    ''find out if wider or taller, then find ratio
    If MyHeight >= MyWidth Then
    myRatio = MyWidth / MyHeight
    MyHeight = HW
    MyWidth = MyHeight * myRatio
    LeftBound = (HW - MyWidth) / 2
    TopBound = 0
    Else
    myRatio = MyHeight / MyWidth
    MyWidth = HW
    MyHeight = MyWidth * myRatio
    LeftBound = 0
    TopBound = (HW - MyHeight) / 2
    End If

    Picture1.AutoRe draw = True
    Picture3.AutoRe draw = True
    Picture3.Cls

    Call Picture3.PaintP icture(Picture2 .Picture, _
    LeftBound, TopBound, MyWidth, MyHeight)
    Picture3.Line (LeftBound, TopBound)-(MyWidth + LeftBound, MyHeight + TopBound), , B

    Picture1.Pictur e = Picture3.Image

    End Sub[/code]


    Hope this helps,

    B
    Last edited by Killer42; Feb 15 '08, 02:37 AM. Reason: Added CODE=vb tag

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      mahesh123, what version of VB are you using?

      Comment

      Working...