|
-
Nov 12th, 2003, 03:16 PM
#1
Thread Starter
New Member
back color of MDI Parent form
What is the secret to changing the backcolor property of an MDI Parent form in VB.NET?
Changing this property does not change the back color of an MDI Parent form.backcolor
Regards,
Al Williams
www.luckydogsystems.com
-
Nov 13th, 2003, 01:54 AM
#2
you could try handling the Paint event in a new Thread, here's a quick working example i knocked up....
VB Code:
[Color=Blue]Private[/COLOR] [Color=Blue]Sub[/COLOR] Form1_Paint([Color=Blue]ByVal[/COLOR] sender [Color=Blue]As[/COLOR] [Color=Blue]Object[/COLOR], [Color=Blue]ByVal[/COLOR] e [Color=Blue]As[/COLOR] System.Windows.Forms.PaintEventArgs) [Color=Blue]Handles[/COLOR] [Color=Blue]MyBase[/COLOR].Paint
[Color=Blue]Dim[/COLOR] t [Color=Blue]As[/COLOR] [Color=Blue]New[/COLOR] Threading.Thread([Color=Blue]AddressOf[/COLOR] pnt)
t.Start()
[Color=Blue]End[/COLOR] [Color=Blue]Sub
[/COLOR] [Color=Blue][/COLOR] [Color=Blue]
[/COLOR] [Color=Blue][/COLOR] [Color=Blue][/COLOR] [Color=Blue]Sub[/COLOR] pnt()
[Color=Blue]Dim[/COLOR] bmp [Color=Blue]As[/COLOR] [Color=Blue]New[/COLOR] Bitmap([Color=Blue]MyBase[/COLOR].Width, [Color=Blue]MyBase[/COLOR].Height)
bmp.SetResolution(1, 1)
[Color=Blue]Dim[/COLOR] g [Color=Blue]As[/COLOR] Graphics = Graphics.FromImage(bmp)
g.FillRectangle([Color=Blue]New[/COLOR] SolidBrush(Color.AntiqueWhite), g.ClipBounds)
g.Dispose()
[Color=Blue]MyBase[/COLOR].BackgroundImage = bmp
Application.DoEvents()
[Color=Blue]End[/COLOR] [Color=Blue]Sub
[/COLOR]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 14th, 2003, 11:05 AM
#3
Addicted Member
This works too and is a little easier
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim ctl as Control
For each ctl in me.controls
If type of ctl is mdiclient then
ctl.backcolor = color.fromknowncolor(knowncolor.control)
Enf If
Next
End Sub
-
Nov 14th, 2003, 01:29 PM
#4
Originally posted by Hole-In-One
This works too and is a little easier
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim ctl as Control
For each ctl in me.controls
If type of ctl is mdiclient then
ctl.backcolor = color.fromknowncolor(knowncolor.control)
Enf If
Next
End Sub
a Form isn't a Control , so For each ctl in me.controls wont find the Form , but even if it could , you cant set the Color of an MDI Form with " .backcolor " , they want to change the backcolor of an MDI Form ....
What is the secret to changing the backcolor property of an MDI Parent form in VB.NET?
the only way to change it is through graphics or some serious Subclassing.
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Nov 14th, 2003, 01:47 PM
#5
Addicted Member
-
Nov 14th, 2003, 02:05 PM
#6
As crazy as it sounds Hole-In-One's code does work I found the samething here:
http://www.dotnet247.com/247referenc.../13/66667.aspx
Although I used it in the ControlAdded event to avoid looping too often, although it is the exact samething.
VB Code:
Private Sub Form2_ControlAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.ControlEventArgs) Handles MyBase.ControlAdded
If TypeOf e.Control Is MdiClient Then
e.Control.BackColor = Me.BackColor
End If
End Sub
Sorry i was a bit slow and didn't see your post Hole.
Last edited by Edneeis; Nov 14th, 2003 at 03:21 PM.
-
Nov 14th, 2003, 03:14 PM
#7
I wonder how many charact
What, were we all surprised to learn a Form is actually derived from Control?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|