Solved

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

Posted on 2016-07-22
3
51 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…

839 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