473,756 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 23057
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.co m

"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:uJ******** ******@TK2MSFTN GP12.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.c om> wrote in
message news:%2******** ********@TK2MSF TNGP10.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.co m

"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:uJ******** ******@TK2MSFTN GP12.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.co m

"Colin Neller" <cn*****@gmail. com> wrote in message
news:Ox******** ******@TK2MSFTN GP15.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.c om> wrote
in message news:%2******** ********@TK2MSF TNGP10.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.co m

"Mythran" <ki********@hot mail.comREMOVET RAIL> wrote in message
news:uJ******** ******@TK2MSFTN GP12.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.co m

"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:OL******** ******@TK2MSFTN GP09.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.n et
Jan 5 '06 #7

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

Similar topics

15
9074
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 the purpose of learning to work with C++. It therefore makes some sense for me to give the situation the amount of consideration presented below. To be quite honest, I'm amazed at the amount there is to say about such a seemingly simple...
1
4884
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 mike. :?: Posted Via Usenet.com Premium Usenet Newsgroup Services ----------------------------------------------------------
3
1614
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 stored information to a Rectangle again.
6
2658
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 application. I have the handle for the other application window and can control it, but I cannot figure out how to add a rectangle around it in VB.net. Can anyone help me?
1
1320
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 region. Would seem pretty simple to do this with a region's IsVisible function, but no, IsVisible returns true if any portion of the rectangle is visible. I know I'll eventually get this just by messing around but don't want to unnecesssarily...
0
1210
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 far I haven't dealt much with graphics programmming except drawing a line on a hwnd or similar simple tasks. Now I actually have a problem that I couldn't solve by searching Google
10
5468
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 cannot be done from starting from bottom-right to up-left. The only selection i'm allowed to do is starting from top-left towards bottom-right orientation. The code is:
29
4095
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 seem to work in Safari for Windows 3, nor when I use image.currentStyle.clip in IE 7. Is there a way to do this in those browsers? Am I doing something stupid?
5
2414
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 borders of hte image or the picturebox1. The thing is its getting out of the borders inside the picturebox1 i just cant see it. I want that if the rectangle is out of the borders so it will write something... Now the variables: FirstImage is...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.