Flickering in customized resizing of the form

Author Topic
phoon M
Member

Joined: 03 Jan 2006
Country:
Posts: 1

Posted: 03 Jan 2006 09:03:54

Problem definition :A form shall have a minimum size .When the user changes the width of the form ,the height must also change by the same amount .Similarly when the height of the form changes the width must change by the same amount . The implementation seems simple as shown in the below piece of code ,but this results in lot of fluckering and inconsistency in height and width chnage .

public MyClass
{
InitializeComponent();

this.prevSize = this.Size;
this.handleResize = true;
}

private bool handleResize = false;

protected override void OnResize(EventArgs e)
{
if (!this.handleResize) return;

this.handleResize = false;

int dx = this.Width - this.prevSize.Width;

int dy = this.Height - this.prevSize.Height;

if (Math.Abs(dx) > Math.Abs(dy))
{
this.Size = new Size(this.Width, this.Height + dx);
}
else
{
this.Size = new Size(this.Width + dy, this.Height);
}
this.prevSize = this.Size;

this.handleResize = true;

base.OnResize (e);
}

Regards ,
Saanya

Problem definition :A form shall have a minimum size .When the user changes the width of the form ,the height must also change by the same amount .Similarly when the height of the form changes the width must change by the same amount . The implementation seems simple as shown in the below piece of code ,but this results in lot of fluckering and inconsistency in height and width chnage .

public MyClass
{
InitializeComponent();

this.prevSize = this.Size;
this.handleResize = true;
}

private bool handleResize = false;

protected override void OnResize(EventArgs e)
{
if (!this.handleResize) return;

this.handleResize = false;

int dx = this.Width - this.prevSize.Width;

int dy = this.Height - this.prevSize.Height;

if (Math.Abs(dx) > Math.Abs(dy))
{
this.Size = new Size(this.Width, this.Height + dx);
}
else
{
this.Size = new Size(this.Width + dy, this.Height);
}
this.prevSize = this.Size;

this.handleResize = true;

base.OnResize (e);
}

Regards ,
Saanya
Mark DNZone.com
Zone Administrator

Joined: 09 Aug 2005
Country: Netherlands
Posts: 24

Posted: 11 Jan 2006 12:25:58

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Problem definition :A form shall have a minimum size .When the user changes the width of the form ,the height must also change by the same amount .Similarly when the height of the form changes the width must change by the same amount . The implementation seems simple as shown in the below piece of code ,but this results in lot of fluckering and inconsistency in height and width chnage .

public MyClass
{
InitializeComponent();

this.prevSize = this.Size;
this.handleResize = true;
}

private bool handleResize = false;

protected override void OnResize(EventArgs e)
{
if (!this.handleResize) return;

this.handleResize = false;

int dx = this.Width - this.prevSize.Width;

int dy = this.Height - this.prevSize.Height;

if (Math.Abs(dx) &gt; Math.Abs(dy))
{
this.Size = new Size(this.Width, this.Height + dx);
}
else
{
this.Size = new Size(this.Width + dy, this.Height);
}
this.prevSize = this.Size;

this.handleResize = true;

base.OnResize (e);
}

Regards ,
Saanya
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Sounds like a buffering thing. I dont know how .NET policy is regarding to double buffering, but it might be something worth looking into.

Mark

--
DNZone.com

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Problem definition :A form shall have a minimum size .When the user changes the width of the form ,the height must also change by the same amount .Similarly when the height of the form changes the width must change by the same amount . The implementation seems simple as shown in the below piece of code ,but this results in lot of fluckering and inconsistency in height and width chnage .

public MyClass
{
InitializeComponent();

this.prevSize = this.Size;
this.handleResize = true;
}

private bool handleResize = false;

protected override void OnResize(EventArgs e)
{
if (!this.handleResize) return;

this.handleResize = false;

int dx = this.Width - this.prevSize.Width;

int dy = this.Height - this.prevSize.Height;

if (Math.Abs(dx) &gt; Math.Abs(dy))
{
this.Size = new Size(this.Width, this.Height + dx);
}
else
{
this.Size = new Size(this.Width + dy, this.Height);
}
this.prevSize = this.Size;

this.handleResize = true;

base.OnResize (e);
}

Regards ,
Saanya
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Sounds like a buffering thing. I dont know how .NET policy is regarding to double buffering, but it might be something worth looking into.

Mark

--
DNZone.com
Follow us on twitter Subscribe to our RSS feed
Activate your free membership today | Login | Currency