Solved

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

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now