Solved

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

Posted on 2016-07-22
3
64 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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