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

RECT - Rectangle

I have a question regarding the RECT structure required for PInvoke calls.
I was reviewing the Rectangle structure (System.Drawing.Rectangle) and it
occurred to me that I may be able to use this structure in place of defining
a RECT structure. I would create the RECT structure definition the same as
the Rectangle structure is defined. Is there any problems with using
Rectangle in place of RECT for the API functions?

Thanks,
Mythran

Jan 4 '06 #1
6 23011
Mythran,

Yes, you can use the System.Drawing.Rectangle structure in place of the
RECT structure in interop calls. The structure layout is the same.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
I have a question regarding the RECT structure required for PInvoke calls.
I was reviewing the Rectangle structure (System.Drawing.Rectangle) and it
occurred to me that I may be able to use this structure in place of
defining a RECT structure. I would create the RECT structure definition
the same as the Rectangle structure is defined. Is there any problems with
using Rectangle in place of RECT for the API functions?

Thanks,
Mythran

Jan 4 '06 #2
Nicholas,

Are you sure about this? It seems at first glance that the Rectangle class
uses left, top, *width*, *height* while RECT uses left, top, *right*,
*bottom*. Also, I think I remember seeing strange behavior when I tried
using the Rectangle class (changing to RECT fixed the problem.)

--
Colin Neller
http://www.colinneller.com/blog
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Mythran,

Yes, you can use the System.Drawing.Rectangle structure in place of the
RECT structure in interop calls. The structure layout is the same.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
I have a question regarding the RECT structure required for PInvoke calls.
I was reviewing the Rectangle structure (System.Drawing.Rectangle) and it
occurred to me that I may be able to use this structure in place of
defining a RECT structure. I would create the RECT structure definition
the same as the Rectangle structure is defined. Is there any problems
with using Rectangle in place of RECT for the API functions?

Thanks,
Mythran


Jan 4 '06 #3
Colin,

Yes, I am. The fields internally are laid out in the same way that the
RECT structure does. The property that you see, Right, is returned on the
fly, and there is not a backing store for it in the class.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Colin Neller" <cn*****@gmail.com> wrote in message
news:Ox**************@TK2MSFTNGP15.phx.gbl...
Nicholas,

Are you sure about this? It seems at first glance that the Rectangle
class uses left, top, *width*, *height* while RECT uses left, top,
*right*, *bottom*. Also, I think I remember seeing strange behavior when
I tried using the Rectangle class (changing to RECT fixed the problem.)

--
Colin Neller
http://www.colinneller.com/blog
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Mythran,

Yes, you can use the System.Drawing.Rectangle structure in place of
the RECT structure in interop calls. The structure layout is the same.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
I have a question regarding the RECT structure required for PInvoke
calls. I was reviewing the Rectangle structure (System.Drawing.Rectangle)
and it occurred to me that I may be able to use this structure in place
of defining a RECT structure. I would create the RECT structure
definition the same as the Rectangle structure is defined. Is there any
problems with using Rectangle in place of RECT for the API functions?

Thanks,
Mythran



Jan 4 '06 #4
Nick,
Yes, I am. The fields internally are laid out in the same way that the
RECT structure does.
No they aren't, Colin is correct.

The property that you see, Right, is returned on the
fly, and there is not a backing store for it in the class.


Exactly, whereas in RECT "right" it's a field on its own.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 4 '06 #5
Yep, you are right.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OL**************@TK2MSFTNGP09.phx.gbl...
Nick,
Yes, I am. The fields internally are laid out in the same way that
the
RECT structure does.


No they aren't, Colin is correct.

The property that you see, Right, is returned on the
fly, and there is not a backing store for it in the class.


Exactly, whereas in RECT "right" it's a field on its own.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jan 4 '06 #6
Mythran wrote:
I have a question regarding the RECT structure required for PInvoke
calls. I was reviewing the Rectangle structure
(System.Drawing.Rectangle) and it occurred to me that I may be able to
use this structure in place of defining a RECT structure. I would
create the RECT structure definition the same as the Rectangle structure
is defined. Is there any problems with using Rectangle in place of RECT
for the API functions?

Thanks,
Mythran

No you can't, the layout don't fit. This one works (at least form me :-) )

public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}

I originaly have it from this article:
http://www.codeproject.com/csharp/win32.asp

HTH,
Andy
--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Jan 5 '06 #7

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

Similar topics

15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
1
by: meicher | last post by:
Hello, There exists a very good methode in C++ and MFC: pDC->invertRectangle(pRec); Is there any simular methode in C# and .Net ? How can I use the API function <invertRectangle> in C# ? Regards...
3
by: Michael Wong | last post by:
Hi, I am new to C# and would like to store a Rectangle structure to the registry, using the following syntax: reg.SetValue(szRectangle,rect); but then I don't know how to retrieve the...
6
by: Alex Pierson | last post by:
I searched the VB and VB.net groups endlessly and cannot find any code to help me do this. What I'm trying to do is to draw a highlighted rectangle around a child window from another...
1
by: PJ6 | last post by:
I've Googled this but come up short... I have a non-rectangular region that contains a moveable rectangle. I want to restrict the rectangle's movement to have it always fully contained in this...
0
by: =?ISO-8859-15?Q?Mathias_W=FChrmann?= | last post by:
Hi, first, I want to apologize for any bad english that might be following and lead to none or bad understanding of my posting. It has been a long time since I last posted in english ;-) So...
10
by: kimiraikkonen | last post by:
Hi, If previous post was missing, here's the complete one: I'm trying to draw a rectange on a picturebox image using mouse move event but the problem is that the rectangle selection / drawing...
29
by: Chris Riesbeck | last post by:
I have an image with a class and the class defines a clip rectangle. In Firefox 2 and 3, and Opera 9, I can access the rectangle with document.defaultView.getComputedStyle(). But that doesn't...
5
by: Chocolade | last post by:
I have a code with a mouseUp event. In this event im drawing with the mouse a rectangle inside a picturebox1 on image. Now the problem is when i draw the rectangle too big so its getting out the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.