Solved

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

Posted on 2016-07-22
3
45 Views
Last Modified: 2016-10-04
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
Comment
Question by:Member_2_7967566
3 Comments
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 41786116
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
 

Author Comment

by:Member_2_7967566
ID: 41786591
Hello,

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

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question