Compiler error CS1518

  • Thread starter Thread starter Phil Da Lick!
  • Start date Start date
P

Phil Da Lick!

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!!
 
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 said:
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?
 
redeclare your own rectangle struct using a definition from www.pinvoke.net.


Phil Da Lick! said:
Mattias said:
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?
 
Back
Top