PDA

Click to See Complete Forum and Search --> : How do I resize a form to match a bitmap?


jjg
Jun 2nd, 2001, 06:58 PM
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

Sastraxi
Jun 2nd, 2001, 08:20 PM
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.

jjg
Jun 2nd, 2001, 09:53 PM
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

Megatron
Jun 3rd, 2001, 11:17 AM
Private Sub Form_Resize()
Me.PaintPicture Picture1.Picture, 0, 0, ScaleWidth, ScaleHeight
End Sub