469,327 Members | 1,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

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 22250
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Steven T. Hatton | last post: by
1 post views Thread by meicher | last post: by
3 posts views Thread by Michael Wong | last post: by
6 posts views Thread by Alex Pierson | last post: by
reply views Thread by =?ISO-8859-15?Q?Mathias_W=FChrmann?= | last post: by
10 posts views Thread by kimiraikkonen | last post: by
29 posts views Thread by Chris Riesbeck | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.