473,388 Members | 1,600 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,388 software developers and data experts.

Size from two Point variables

I have to Point variables that are being set on MouseDown and MouseUp
events --

mousedownPoint = new Point(e.X, e.Y);
mouseupPoint = new Point(e.X, e.Y);

Is there a way that I can take those two points and get a Height and Width
value from it to use for a Size variable? I have tried many different ways
but none of them have worked.

Thanks

Dan
Feb 15 '07 #1
2 1833

You can convert the points to sizes and then use Size subtraction, but
have to deal with issues like did they drag from top/left to
bottom/right or reverse.

I think easiest is to just perform math separately and then create a
size structure from that:

height = Math.Abs(mousedownPoint.X - mouseupPoint.X);
width = Math.Abs(mousedownPoint.Y - mouseupPoint.Y);

Size sz = new Size(width, height);

Unless you want the sizes to be negative which is possible depending
on what you're going to do with the data...

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Thu, 15 Feb 2007 12:20:21 -0500, "Dan Reber" <dr****@nospam.com>
wrote:
>I have to Point variables that are being set on MouseDown and MouseUp
events --

mousedownPoint = new Point(e.X, e.Y);
mouseupPoint = new Point(e.X, e.Y);

Is there a way that I can take those two points and get a Height and Width
value from it to use for a Size variable? I have tried many different ways
but none of them have worked.

Thanks

Dan
Feb 15 '07 #2
Thanks, Sam.

"Samuel R. Neff" <sa********@nomail.comwrote in message
news:tv********************************@4ax.com...
>
You can convert the points to sizes and then use Size subtraction, but
have to deal with issues like did they drag from top/left to
bottom/right or reverse.

I think easiest is to just perform math separately and then create a
size structure from that:

height = Math.Abs(mousedownPoint.X - mouseupPoint.X);
width = Math.Abs(mousedownPoint.Y - mouseupPoint.Y);

Size sz = new Size(width, height);

Unless you want the sizes to be negative which is possible depending
on what you're going to do with the data...

HTH,

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Thu, 15 Feb 2007 12:20:21 -0500, "Dan Reber" <dr****@nospam.com>
wrote:
>>I have to Point variables that are being set on MouseDown and MouseUp
events --

mousedownPoint = new Point(e.X, e.Y);
mouseupPoint = new Point(e.X, e.Y);

Is there a way that I can take those two points and get a Height and Width
value from it to use for a Size variable? I have tried many different
ways
but none of them have worked.

Thanks

Dan

Feb 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
11
by: Bill Cunningham | last post by:
In fread, the type of the function is the typedef size_t. I want to rewrite a program that read binary data of mp3s. int main(){ printf("Enter name of file-> "); char name; fflush(stdout); FILE...
19
by: junky_fellow | last post by:
Can the size of pointer variables of different type may be different on a particular architecture. For eg. Can the sizeof (char *) be different from sizeof(int *) or sizeof (void *) ? What...
8
by: Mark | last post by:
Is there a point when the size of a asp.net web project is too big ... and it really should be broken down into multiple projects? For example, there is a significant difference in .dll size...
11
by: Andy Watson | last post by:
I have an application that scans and processes a bunch of text files. The content I'm pulling out and holding in memory is at least 200MB. I'd love to be able to tell the CPython virtual machine...
53
by: Jonas Smithson | last post by:
In his book "CSS: The Definitive Guide" 2nd edition (pgs. 116-117), Eric Meyer has an interesting discussion about "font-size-adjust" that was evidently dropped in CSS 2.1 due to browser...
13
by: Shutey | last post by:
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on a fast XP pro PC, I have a form which requires 5 dropdowns populated with indentical values. I extract the values using SQL...
15
by: kris | last post by:
Hi I am writing a small program where I need to obtain the actual size of a structure. The programm is as follows struct abc { int j; char k; int i; }*a;
9
by: raashid bhatt | last post by:
does having more variables increases the size of program.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.