Customize Windows.Forms.MdiClient

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?bGpsZXZlbmQy?=

    Customize Windows.Forms.MdiClient

    Is there any way to change or turn off the border of an
    Windows.Forms.M diClient 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

  • Cor Ligthert [MVP]

    #2
    Re: Customize Windows.Forms.M diClient

    Lance,

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



    Cor


    "ljlevend2" <ljlevend2@nosp am.nospamschree f in bericht
    news:037DD36E-6B59-400D-A9BE-B67EF016FDB5@mi crosoft.com...
    Is there any way to change or turn off the border of an
    Windows.Forms.M diClient 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
    >

    Comment

    • =?Utf-8?B?bGpsZXZlbmQy?=

      #3
      Re: Customize Windows.Forms.M diClient

      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

      Comment

      • Stephany Young

        #4
        Re: Customize Windows.Forms.M diClient

        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(ByVa l sender As Object, ByVal e As EventArgs)
        Handles MyBase.Load

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

        End Sub

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

        m_mdiclient.Doc k = DockStyle.None

        m_mdiclient.Loc ation = New Point(-2, -2)

        m_mdiclient.Siz e = New Size(ClientSize .Width + 4, ClientSize.Heig ht + 4)

        End Sub

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

        m_mdiclient.Doc k = 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" <ljlevend2@nosp am.nospamwrote in message
        news:9B56A6CF-E35C-40AF-A3F3-26EEEEFF145D@mi crosoft.com...
        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
        >

        Comment

        • Linda Liu [MSFT]

          #5
          RE: Customize Windows.Forms.M diClient

          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
          Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

          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.

          Comment

          • =?Utf-8?B?bGpsZXZlbmQy?=

            #6
            Re: Customize Windows.Forms.M diClient

            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

            Comment

            • =?Utf-8?B?bGpsZXZlbmQy?=

              #7
              RE: Customize Windows.Forms.M diClient

              Thanks Linda. Your help is always very much appreciated!
              Lance

              Comment

              Working...