473,406 Members | 2,356 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,406 software developers and data experts.

Compiler error CS1518

Hi,

Because GDI+ doesnt support inversion of rectangles on a graphics device
(!!!) I'm attempting to call InvertRect() on the api direct from my c#
project.

In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.

Help!!
Jul 22 '05 #1
3 3893
>In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.

P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 22 '05 #2
Mattias Sjögren wrote:
In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);

The bool on the last line is generating the error. I'm using VS pro 2003.
P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".


That's a typo.

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Any way to convert?
Jul 22 '05 #3
redeclare your own rectangle struct using a definition from www.pinvoke.net.
"Phil Da Lick!" <ph***********@NOSPAMhotmail.com> schrieb im Newsbeitrag
news:#P**************@TK2MSFTNGP10.phx.gbl...
Mattias Sjögren wrote:
In the file in questions, directly after the using directives and before
the class/namespace bit I've got (found this on the web):

[DllImport("user32.dll")]
[return:MarshalAs(UnmanagedType.Bool)]
public static bool InvertRect(IntPtr hDC, rf System.Drawing.Rectangle lprc);
The bool on the last line is generating the error. I'm using VS pro
2003.
P/Invoke method declarations must be placed inside a type (class or
struct) just like any other method.

In addition to that, you must add the extern keyword to the
declaration, and change "rf" to "ref".


That's a typo.

But even then it will not work as expected, because the internal
layout of a System.Drawing.Rectangle isn't the same as a GDI RECT
struct.


Any way to convert?

Jul 22 '05 #4

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

Similar topics

0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
1
by: Ayende Rahien | last post by:
reparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error (0xc0000005 at address 53168B12): likely culprit is 'BIND'. An internal...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
4
by: David Sworder | last post by:
Consider the following line of code (it's not important what it does): resp.DocItem=Relations.SelectDocItems_BySearchString(req.SearchPhrase); It turns out that this line is in error. The...
1
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error...
3
by: Phil Da Lick! | last post by:
Hi, Because GDI+ doesnt support inversion of rectangles on a graphics device (!!!) I'm attempting to call InvertRect() on the api direct from my c# project. In the file in questions, directly...
9
by: blackdog | last post by:
I compiled *.cs which contains public partial class xxx: System.Web.UI.Page I got errors as below: xxx_cs.aspx.cs: error CS1518: Expected class, delegate, enum, interface, or struck. Please...
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.