Painting MDI Form

F

Frank Liebelt

Hi

Does anyone know a method to paint a gradient background to an MDI
Container?

I tried to use the Blend Control from VBPowerPack but each MDI Child will be
shown behind that control.
I tried BringToFront() or SendToBack() but have no results.

Now im searching for a method to paint a gradient background to that MDI
form.
This gradient must be repainted if the user changed the MDI Container size.

My last visit was here:
http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows/MDI_Client_Area_Painting/article.asp

This looks excactly like what i want.

Thanks for any help

Frank
 
K

Ken Tucker [MVP]

Hi,

Draw on a bitmap and set the mdi forms background image to the
bitmap. Try something like this

Dim WithEvents frm As New Form2

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

frm.MdiParent = Me

frm.Show()

End Sub

Private Sub DrawBackground()

Dim lbBack As New LinearGradientBrush(Me.ClientRectangle, Color.Blue,
Color.White, LinearGradientMode.ForwardDiagonal)

Dim bm As New Bitmap(Me.Width, Me.Height)

Dim g As Graphics = Graphics.FromImage(bm)

g.FillRectangle(lbBack, 0, 0, Me.ClientRectangle.Width,
Me.ClientRectangle.Height)

Me.BackgroundImage = bm

lbBack.Dispose()

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

DrawBackground()

End Sub


Private Sub frm_Move(ByVal sender As Object, ByVal e As System.EventArgs)
Handles frm.Move

DrawBackground()

End Sub



Ken

-------------------------

Hi

Does anyone know a method to paint a gradient background to an MDI
Container?

I tried to use the Blend Control from VBPowerPack but each MDI Child will be
shown behind that control.
I tried BringToFront() or SendToBack() but have no results.

Now im searching for a method to paint a gradient background to that MDI
form.
This gradient must be repainted if the user changed the MDI Container size.

My last visit was here:
http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows/MDI_Client_Area_Painting/article.asp

This looks excactly like what i want.

Thanks for any help

Frank
 
F

Frank Liebelt

Hi Ken
Draw on a bitmap and set the mdi forms background image to the
bitmap. Try something like this

Dim WithEvents frm As New Form2

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

frm.MdiParent = Me

frm.Show()

End Sub

Private Sub DrawBackground()

Dim lbBack As New LinearGradientBrush(Me.ClientRectangle, Color.Blue,
Color.White, LinearGradientMode.ForwardDiagonal)

Dim bm As New Bitmap(Me.Width, Me.Height)

Dim g As Graphics = Graphics.FromImage(bm)

g.FillRectangle(lbBack, 0, 0, Me.ClientRectangle.Width,
Me.ClientRectangle.Height)

Me.BackgroundImage = bm

lbBack.Dispose()

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

DrawBackground()

End Sub


Private Sub frm_Move(ByVal sender As Object, ByVal e As System.EventArgs)
Handles frm.Move

DrawBackground()

End Sub

That helps me. Thank you

Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top