Xojo.RECT circular Errors

In Xojo 2019 r3.1 on Windows 10, I need to use a definition of RECT for declares when drawing tooltips.

I must define a RECT, as Xojo.RECT is already defined by class Xojo.RECT in API2 (this did not happen in API1).

Here is how I define a RECT:

Structure RECT Left as Int32 Top as Int32 Right as Int32 Bottom as Int32 End Structure
The error is:

The next step was then to remove the RECT definition, and replace with Xojo.Rect. I then get the error:

Is there a way to either:

  1. use Xojo.Rect in a structure
  2. ignore Xojo.Rect when using declares

As a workaround, I can redefine RECT as RECT1 and ignore Xojo.RECT which will allow me to use RECT in a structure.

Any helpful hints? Thanks.

Does it have to be a Rect?
Wouldnt passing a memoryblock of the right size do the trick, whatever it is called, and whichever API1 or API2 was in use?

[quote=487116:@Jeff Tullin]Does it have to be a Rect?
Wouldnt passing a memoryblock of the right size do the trick, whatever it is called, and whichever API1 or API2 was in use?[/quote]
Hi Jeff,

Yes, that is an option that would work. Thanks for the suggestion.

The type name doesn’t matter. You could call the structure you are creating “MyRect” and it would work fine. So maybe just change what you are naming the structures you make for declares?

I agree Jason.

I am following the naming convention for Microsoft. What I am really curious about is that I can’t use a Xojo.RECT in a structure, but yet I can use almost all of the other data types in a structure?

That is because it is class and not a structure.

The fact that the compiler can’t distinguish between the Xojo.Rect class and a Structure you named Rect in a different module or class based on scope alone, never mind context, is unfortunate to say the least given how much existing code has declares using structures named Rect

-Karen

The new Xojo Rect uses doubles anyway, doesn’t it?
It wouldn’t be compatible even if one of the exposed properties was an array of the Left,Top, Right , and bottom

https://documentation.xojo.com/api/graphics/rect.html

[quote=487176:@Jeff Tullin]The new Xojo Rect uses doubles anyway, doesn’t it?
It wouldn’t be compatible even if one of the exposed properties was an array of the Left,Top, Right , and bottom[/quote]
Thanks Jeff. I will look into this.

You’ll need it as a structure if you’re passing it through declares so using the new class won’t work, a memoryblock is a bit overkill for something so simple.

I guess we’ll have to fall back to RECTL which is just the same as RECT in win32 land, but its just a name in xojo at the end the day, yay, more borked old code :frowning:

Hi Julian,

I renamed RECT to RECT1 and it works well. Xojo.Rect is ignored as its not compatible. I didn’t know about RECTL, and that might be used in a future project. Thanks!