Results 1 to 4 of 4

Thread: How do I resize a form to match a bitmap?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Location
    Seattle
    Posts
    6

    Question How do I resize a form to match a bitmap?

    I have an MDIChild form that opens from the MDIParents menu and displays a graphic(bmp,gif,jpg). My problem is that the MDIChild form needs to be match the size of the graphic, either by resizing the form or by resizing the graphic. Any help will be greatly appreciated.
    TIA
    J

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Load the pic in an invisible pic box. Take the width & height from there. Put the pic on the form, and REMOVE the picturebox from the form. Then, me.height = the_height * screen.twipsperpixely , me.width = the_width * screen.twipsperpixelx. This will do the first one of your options.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2001
    Location
    Seattle
    Posts
    6
    Thanks Sastraxi, I'm a little confused just how to REMOVE a pic box and which form all this should be taking place on. The files are opened with a common dialog control.

    -----------------MDI--------------------
    Option Explicit

    Public pic As StdPicture
    Private Sub mnuFileOpen_Click()
    Dim myFlags As FileOpenConstants
    myFlags = cdlOFNExplorer + cdlOFNFileMustExist

    With cdl1
    .Filter = "Graphics Files|*.jpg;*.gif;*.bmp|All Filles|*.*"
    .Flags = myFlags
    .CancelError = True
    .InitDir = "c:\windows"
    .DialogTitle = "Choose Picture"
    .ShowOpen
    Form1.Cls
    Set pic = LoadPicture(.FileName)
    Form1.Picture1.Picture = pic
    End With

    End Sub

    -------------------------child------------------
    Option Explicit
    Public nuWidth As Integer
    Public nuHigh As Integer

    Private Sub Form_Load()
    nuWidth = Picture1.ScaleWidth
    nuHigh = Picture1.ScaleHeight

    End Sub

  4. #4
    Megatron
    Guest
    VB Code:
    1. Private Sub Form_Resize()
    2.     Me.PaintPicture Picture1.Picture, 0, 0, ScaleWidth, ScaleHeight
    3. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width