473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Odd things happening with custom sizing code

HaLo2FrEeEk
404 256MB
I've written a program that has a secondary form with panels in each corner and the center of each edge, and one in the middle. These panels act as sizing and moving handles, and they've got custom code behind them to help them do that. I wrote in some checks to make sure the form couldn't be resized or moved outside of the screen boundaries and for the most part it works, but I noticed something odd happening when I grab any of the top or left handles (so bottom-left, left, top-left, top, and top-right) and flick it to the corresponding edge of the screen very quickly. What happens is the code stops it from going outside the screen bounds, but it also causes the form to resize itself and become smaller each time. Here's a current build of the program:

http://infectionist.com/extras/cshar...shot_1.6.1.zip

Just grab the top handle and whip it to the top of the screen really quickly while watching the bottom of the form, you'll see that it moves the bottom of the form up as well. It shouldn't do this. This is the full event handler I have for the MouseMove event on my "Top" edge handle:

Expand|Select|Wrap|Line Numbers
  1. private void hndlTop_MouseMove(object sender, MouseEventArgs e)
  2. {
  3.     if(moveSizeMode == MoveSizeMode.Top)
  4.     {
  5.         newBounds = new Rectangle(this.Left, this.Top + e.Y - Lock.Y, this.Width, this.Height - e.Y + Lock.Y);
  6.         if (this.Bottom - newBounds.Y < this.MinimumSize.Height)
  7.             newBounds.Y = this.Bottom - this.MinimumSize.Height;
  8.         if (newBounds.Y < 0)
  9.         {
  10.             newBounds.Y = 0;
  11.             newBounds.Height = this.Height;
  12.         }
  13.  
  14.         this.Bounds = newBounds;
  15.         doPositioning(false, false);
  16.     }
  17. }
I can't see anything wrong with it, but obviously something is wrong, it should act just like a Windows Form when it gets to the top of the screen, just stop resizing.

Right now this is the only thing keeping me from releasing the app, so please, can someone help me figure this out?

Edt: I put in a MessageBox at the beginning and end of the if...then (newBounds.Y < 0) to just echo out the newBounds rectangle, here is the before and after:

Before: {X=358,Y=-12,Width=1142,Height=484}
After: {X=358,Y=0,Width=1142,Height=421}

There is a difference of -63 in the height after.
Jan 2 '11 #1

✓ answered by HaLo2FrEeEk

Ok, nevermind I figured it out. All I had to do was move the newBounds.Height = this.Height code above the newBounds.Y = 0, and change it to newBounds.Height = newBounds.Bottom.

1 1135
HaLo2FrEeEk
404 256MB
Ok, nevermind I figured it out. All I had to do was move the newBounds.Height = this.Height code above the newBounds.Y = 0, and change it to newBounds.Height = newBounds.Bottom.
Jan 3 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Judy | last post by:
I have a custom menu that is only used for one form. Is there a way to put the functions for the menu items in the form's module rather than a standard module? Thanks! Judy
1
by: Brian Munroe | last post by:
Let me preface this post: This is my first web app in ASP.NET, I am sure I did things very kludgy, so please bare with my possibly stupid ASP.NET design. I am trying to create a custom error...
2
by: Mark in Miami | last post by:
I started developing a project in VB.NET v. before 2003. THEN, I upgraded to 2003, not the original form created in the other version doesn't populate fields loaded from the database. I stepped...
10
by: Aris | last post by:
Hello! This is my problem. I'm trying to make an inorder traversal algorithm for a binary tree, not a recursive one, but using a stack. Till now I got this: void traverse(tree * p) { l:...
0
by: rodchar | last post by:
hey all, i have a bound drop-down list where the contents change all the time. i'm having trouble with the SelectedValue binding because there's a scenario where the value could be null, in which...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
1
by: Andreas Bergmeier | last post by:
Hi. Is there some KB article how to use EnableEventValidation when doing customized posts? Basicly we're building a post string via javascript and issue it via means of XMLHttpRequest to the...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
1
by: Artie | last post by:
Hi, Is there any way to tell an XSD Schema that you want custom error codes for particular validation failures in an XML document? To show what I mean, here's an example: XSD excerpt: ...
1
by: koti688 | last post by:
Hi Mates, Can u please tell me whats happpenning in those. Please tell what ever u got. Outline the functinaliy in normal words. i am new to C++. I need to write SWIG wrapper which checks this C++...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.