Visual Basic.NET - Imagen de fondo para MDI

 
Vista:

Imagen de fondo para MDI

Publicado por Damian (824 intervenciones) el 04/11/2008 17:22:54
Me gustaría insertar una imagen de fondo en un formulario MDI, pero haga lo que haga la imagen que inserto después se me superpone a los formularios hijos que abra.
-Coloco la imagen en Image de un pictureBox dentro del formulario MDI, se me superpone a otros formularios que abro desde el formulario MDI.
-Si coloco la imagen en backgroundImage de un pictureBox dentro del formulario MDI, me pasa lo mismo.

¿Alguien sabe como hacerlo?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Imagen de fondo para MDI

Publicado por Harold V. (411 intervenciones) el 04/11/2008 23:50:50
Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'MDI //////////////////////////////
Dim MdiC As MdiClient = New System.Windows.Forms.MdiClient()

With MdiC
.Dock = System.Windows.Forms.DockStyle.Fill
.Name = "MdiC"
.BackColor = Color.White
.BackGroundimage=aqui_va_tu_imagen
End With

Me.Controls.AddRange(New System.Windows.Forms.Control() {MdiC})
Me.IsMdiContainer = True
'////////////////////////////////////////////////////////////////////////////////////////////////

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Imagen de fondo para MDI

Publicado por Damian (824 intervenciones) el 05/11/2008 16:18:59
Gracias Harold, copie tal cual el codigo pero me sigue pasando lo mismo, cada vez que abro los formularios hijos estos se esconden atras de la imagen que cargo en BackGroundimage asi que nunca los puedo ver.......
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Imagen de fondo para MDI

Publicado por jose (1 intervención) el 23/07/2011 22:27:52
No necesitas declarar DLL, ni otras cosas por el estilo
Stretched MDI Background Image in VB.Net

Here's a simple example showing how to paint an image across the background of an MDI container form stretching the image to fill the whole form width and height. Normally, if you just set the background image property of the MDI form, you will get the image tiled at its original size multiple times across the form. Using the method shown below, the image will stretch itself larger or smaller to fit the entire size of the form.

Add a picture box to the MDI form. I've called mine pbBackground.
Add the following code to the MDI form load event:
' Get the mdiclient area control to paint the background for us
For Each c As Control In Me.Controls
If TypeOf c Is MdiClient Then
AddHandler c.Paint, AddressOf myMdiControlPaint
AddHandler c.SizeChanged, AddressOf myMdiControlResize
Exit For
End If
Next

Add the following two functions:
Private Sub myMdiControlPaint(ByVal sender As Object, _
ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.DrawImage(Me.pbBackground.Image, 0, 0, Me.Width, Me.Height)
End Sub

Private Sub myMdiControlResize(ByVal sender As Object, _
ByVal e As System.EventArgs)
CType(sender, MdiClient).Invalidate()
End Sub

If you wanted to centre the image, or amend the size so it scales but does not lose its original aspect ratio, you can easily do that in the myMdiControlPaint function. The last 4 parameters of the DrawImage function are top, left, width and height, respectively.

If you use a PNG format file, you can include transparency in the image that will show the background colour of the form through. I've used this so you can still change the background colour of the form, but have a transparent company logo in the corner, like a watermark.

You will some get flickering when the form is redrawn or resized using the method shown above. I haven't found a way round this yet...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar