Shaped Forms Question

F

Flix

I need some help to handle the Region property of my Form in the correct
way.
Usually when I create shaped forms in my programs, I modify the Form.Region
property, making it include only a part of the form client rectangle (I use
a custom button to close my form).
The problem is that when I want to go back to a normal shaped form at
runtime, I use the following line of code:

this.Region=new System.Drawing.Region(new
System.Drawing.Rectangle(0,0,this.Width,this.Height));

This line works, but creates an old fashioned flat titlebar, not a XP style
titlebar.
This effect is very easily observable: just put the line above at the end of
a Form constructor and run the program.
I tried with Application.EnableVisualStyles(), but it doesn't seem to work.
The Form class doesn't have a FlatStyle property to be set to System.
Any help is welcome. Thank you in advance.
 
C

Chris Jobson

If you just want to restore the form to its "default" state then you don't
need a region at all, so
this.Region = null;
should work.

Chris Jobson
 
F

Flix

Chris Jobson said:
If you just want to restore the form to its "default" state then you don't
need a region at all, so
this.Region = null;
should work.

Thank you. I will try it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C# Irregular shaped user controls. 3
Hit Detection on a Line 2
Shaped Windows Forms 3
Non-rectangular forms 1
AntiAliased Form 2
Shaped Forms 4
Regions and Windows XP 2
Transparency of shaped forms? 5

Top