[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

carl.manaster@gmail.com

12/20/2004 8:20:00 PM

I'm pretty new to dotnet; sorry if this is a FAQ but I've reviewed
usenet and the FAQs I could find without success.

I'm drawing fancy windows - funny shapes that resize in odd ways - and
have the Region generation down pretty well, but my Region is clipped
to the Form's boundary rectangle.

Fine, I thought - I'll just make it really big. Unfortunately, when I
move or resize the Form, it "snaps" it back onscreen (or at least below
the top).

I tried working around this by resizing and translating the window to
fit just around where the Region belongs, then offsetting the Region
within the window, but found myself down a rathole - plus, I really
want the possibility of having part of the window offscreen, including
off the top of the screen.

Is there a way to prevent the snapping? I don't want a universal
setting to change - I don't want to mess with existing behavior for
normal windows - just something (an event, maybe) to override in my
Form subclass to block this behavior for the custom forms.
Thanks,
--Carl

3 Answers

Bob Powell

12/20/2004 8:54:00 PM

0

The form size shouldn't matter if you've correctly set the Form.Region
property.

How are you painting your oddly shaped form, can you post some example that
shows the problem you're having?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tips...

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/f...

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





<carl.manaster@gmail.com> wrote in message
news:1103571596.957371.202430@z14g2000cwz.googlegroups.com...
> I'm pretty new to dotnet; sorry if this is a FAQ but I've reviewed
> usenet and the FAQs I could find without success.
>
> I'm drawing fancy windows - funny shapes that resize in odd ways - and
> have the Region generation down pretty well, but my Region is clipped
> to the Form's boundary rectangle.
>
> Fine, I thought - I'll just make it really big. Unfortunately, when I
> move or resize the Form, it "snaps" it back onscreen (or at least below
> the top).
>
> I tried working around this by resizing and translating the window to
> fit just around where the Region belongs, then offsetting the Region
> within the window, but found myself down a rathole - plus, I really
> want the possibility of having part of the window offscreen, including
> off the top of the screen.
>
> Is there a way to prevent the snapping? I don't want a universal
> setting to change - I don't want to mess with existing behavior for
> normal windows - just something (an event, maybe) to override in my
> Form subclass to block this behavior for the custom forms.
> Thanks,
> --Carl
>


carl.manaster@gmail.com

12/20/2004 9:56:00 PM

0

Hi, Bob, and thanks -

> How are you painting your oddly shaped form, can you post
> some example that shows the problem you're having?

Here's an example, boiled down about as far as I can. I replaced my
complex region with a simple circle, but with the topleft at (-10,
-10); you can see when the form is displayed that it is clipped and
only the positive coordinates are displayed.

Peace,
--Carl



using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CircularWindow
{

public abstract class FlexibleForm : Form
{
private Container components = null;

public FlexibleForm()
{
this.FormBorderStyle = FormBorderStyle.None;
InitializeComponent();
this.Load += new EventHandler(MakeShape);
}

protected void MakeShape(object sender, EventArgs e) {MakeRegions();}
protected void MakeRegions()
{
Region = MakeFormRegion();
}
protected abstract Region MakeFormRegion();

private void DisposeComponents()
{
if (components != null) components.Dispose();
}

protected override void Dispose(bool disposing)
{
if(disposing)
{DisposeComponents();}
base.Dispose(disposing);
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = Color.Red;
this.ClientSize = new System.Drawing.Size(300, 300);
this.Name = "FlexibleForm";
this.Text = "FlexibleForm";
}
#endregion
}
public class CircularForm:FlexibleForm
{
public CircularForm()
{
}
protected override Region MakeFormRegion()
{
GraphicsPath path = new GraphicsPath();

// here you see that the region includes negative coordinates;
// these are clipped out when the form is drawn
path.AddArc(new Rectangle(-10, -10, 100, 100), 0, 360);
path.CloseFigure();
return new Region(path);
}
[STAThread]
static void Main()
{
Application.Run(new CircularForm());
}
}
}

carl.manaster@gmail.com

12/21/2004 11:12:00 PM

0

I've solved it; Just set the WindowState to Maximized in the
constructor, thus:

this.WindowState = FormWindowState.Maximized;

It seems to do the trick, although I fear it will not work right on
multiple monitor configurations.

Peace,
--Carl