PC Review


Reply
Thread Tools Rate Thread

Customize Windows.Forms.MdiClient

 
 
=?Utf-8?B?bGpsZXZlbmQy?=
Guest
Posts: n/a
 
      23rd Feb 2007
Is there any way to change or turn off the border of an
Windows.Forms.MdiClient control? In my opinion the 3D bevel that the control
uses is outdated and looks poor in my app. The best would be a single line
border that custom draw so I can control the color of the border.

Thanks for any help!
Lance

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      24th Feb 2007
Lance,

You can forever change everything in VB.Net. See here your border around a
textbox.

http://www.vb-tips.com/dbpages.aspx?...0-58fd21b7e2ea

Cor


"ljlevend2" <(E-Mail Removed)> schreef in bericht
news:037DD36E-6B59-400D-A9BE-(E-Mail Removed)...
> Is there any way to change or turn off the border of an
> Windows.Forms.MdiClient control? In my opinion the 3D bevel that the
> control
> uses is outdated and looks poor in my app. The best would be a single
> line
> border that custom draw so I can control the color of the border.
>
> Thanks for any help!
> Lance
>



 
Reply With Quote
 
=?Utf-8?B?bGpsZXZlbmQy?=
Guest
Posts: n/a
 
      25th Feb 2007
Hi Cor,

Thanks for the idea. Unfortunately the sample will not work for the
following reasons:

1. The sample does not address the need to change the width of the border.
2. The Paint event of the form will not necessarily be fired when the border
of its MdiClient control needs to be updated.
3. The sample will never work as it is written (even for a TextBox) because
it uses the Graphics object that is passed to the form's Paint event which
corresponds to the client area of the form, not the client area of the
control.

Any other ideas?

Thanks,
Lance

 
Reply With Quote
 
Stephany Young
Guest
Posts: n/a
 
      26th Feb 2007
Try this.

Create a Windows Forms project and set the IsMDiContainer property to True.

Note that the MdiClient area has a sunken 3D border.

Add 2 Buttons (Button1 and Button2) to the form and add the following code.

Dim m_mdiclient As MdiClient = Nothing

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

For Each _c As Control In Me.Controls
If _c.GetType Is GetType(MdiClient) Then
m_mdiclient = CType(_c, MdiClient)
Exit For
End If
Next

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles Button1.Click

m_mdiclient.Dock = DockStyle.None

m_mdiclient.Location = New Point(-2, -2)

m_mdiclient.Size = New Size(ClientSize.Width + 4, ClientSize.Height + 4)

End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles Button2.Click

m_mdiclient.Dock = DockStyle.Fill

End Sub

'Run' the project.

Note that the MdiClient area has a sunken 3D border.

Click Button1.

Note that the MdiClient area repaints and no longer has a sunken 3D border.

Click Button2.

Note that the MdiClient area repaints and has a sunken 3D border again.

Click Button1 and then resize the form.

There is still a single, slightly darker line that appears to be around the
MdiClient area it is really the inside edge of the form border.

If you don't reposition and resize the MdiClient area when you set it's Dock
property to DockStyle.None, then it's location becomes 0,0 and it's size
becomes 0,0 which, of course becomes problems.

Have a play with that and see if it helps with what you are trying to
achieve.


"ljlevend2" <(E-Mail Removed)> wrote in message
news:9B56A6CF-E35C-40AF-A3F3-(E-Mail Removed)...
> Hi Cor,
>
> Thanks for the idea. Unfortunately the sample will not work for the
> following reasons:
>
> 1. The sample does not address the need to change the width of the border.
> 2. The Paint event of the form will not necessarily be fired when the
> border
> of its MdiClient control needs to be updated.
> 3. The sample will never work as it is written (even for a TextBox)
> because
> it uses the Graphics object that is passed to the form's Paint event which
> corresponds to the client area of the form, not the client area of the
> control.
>
> Any other ideas?
>
> Thanks,
> Lance
>


 
Reply With Quote
 
Linda Liu [MSFT]
Guest
Posts: n/a
 
      26th Feb 2007
Hi Lance,

I agree to what Stephany has suggested. We could get the MdiClient of a MDI
parent form and set its Dock property to None to turn off the 3D bevel
border on the MDI parent form.

As for changing the color of a form's border, I have spent some time
researching on this problem but didn't find a good way to do it.

On possible way is to override the WndProc method in the form, and catch
WM_NCPAINT message in the override method. The WM_NCPAINT message is sent
to a window when its frame must be painted. However, when we handle the
WM_NCPAINT message, we need to draw the non-client of the form by
ourselves, including the title bar, which may be much complex.

Alternatively, you could set the 'Active Window Border' or 'Inactive Window
Border' for the entire system. To do this, right-click on the destop and
choose 'Properties'. In the Display properties, switch to the Appearance
tab, and click the 'Advanced' button. In the Advanced Appearance window,
select 'Active Window Border' or 'Inactive Window Border' for the 'Item'
and then change its color.

If you have any concerns, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
=?Utf-8?B?bGpsZXZlbmQy?=
Guest
Posts: n/a
 
      27th Feb 2007
Thanks Stephany. I was not aware that the border would change when the
MdiClient is not docked. That should let me do what I want.
Lance

 
Reply With Quote
 
=?Utf-8?B?bGpsZXZlbmQy?=
Guest
Posts: n/a
 
      27th Feb 2007
Thanks Linda. Your help is always very much appreciated!
Lance

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to customize scrollbar of System.Windows.Forms.TreeView Jay Microsoft C# .NET 0 15th Jan 2007 07:11 AM
Customize windows forms datagrid Gav Microsoft Dot NET Framework Forms 0 26th Sep 2005 04:55 PM
System.Windows.Forms.MdiClient+ControlCollection not serializable. Trevor Germain Microsoft Dot NET 0 24th Nov 2003 04:49 PM
System.Windows.Forms.MdiClient+ControlCollection not serializable. Trevor Germain Microsoft Dot NET Framework 0 24th Nov 2003 03:40 PM
System.Windows.Forms.MdiClient+ControlCollection not serializable. Trevor Germain Microsoft Dot NET Framework Forms 0 24th Nov 2003 03:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:09 AM.