• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 90
  • Last Modified:

Form. Region not working when instantiating a form more than once

I'm trying to make all the forms in an existing project (more than 100 forms) look rectangular instead of having circular corner. they all inherit from a customized form.  For that my plan is to change the region of the custom form
like that:
    Private Sub frx_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint

        Using opath As New Drawing2D.GraphicsPath()
            opath.AddRectangle(Me.Bounds)
            Me.Region = New Region(opath)
        End Using

    End Sub


Some forms are instantiated more than once, the first instance shows correctly, but the second does not show at all.

Attached is a sample project that shows the behavior. if you click on the button "show form" it shows the form, when you click on the button a second time, the form doesn't show.
WindowsApplication1.zip
0
Member_2_7967566
Asked:
Member_2_7967566
1 Solution
 
SStoryCommented:
I suppose you could set their border style = none and draw your own borders in the Paint Event.  Then you'd need to make your own min/max buttons, handle all sorts of events, etc.

If that doesn't work, how about creating the one form you want and visually inheriting the form each time it is created?

Here's a sample of that and more: http://www.codeproject.com/Articles/6455/A-Visually-Inheritable-Unbound-Dataform

I'm not sure it will work with your scenario, but worth a try.
0
 
Member_2_7967566Author Commented:
Hello,

I ended up creating a custom form by overriding WndProc to intercept NCPAINT and NCACTIVATE ...
It all works fine.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now