C++ Array of Rect to Delphi Array of Rects

Hello!

  Does anyone know how is the correct way to send an array of Rect from C++ (dll) to the delphi ? I'm using callbacks to receive the information.

Thank you in advance!

Regards,
Everton Soares Manso
0
Everton
3/12/2010 8:00:13 PM
embarcadero.delphi.win32 2183 articles. 0 followers. Follow

3 Replies
874 Views

Similar Articles

[PageSpeed] 58

>   Does anyone know how is the correct way to send an array of Rect from C++ (dll) to the delphi ? I'm using callbacks to receive the information.

assuming you have an array of Rect and the number of elements as an int, you can 
use following function on the caller side:

void __cdecl PassRects(int count, Rect* rects)

You can call it like this:

Rect rects[10];
rects[0] = ...
....
rects[9] = ...
PassRects(10, rects);

On the receiver side use following function:

type
   TRectArray = array[0..$7FFFFFF] of TRect;
   PRectArray = ^TRectArray;

procedure PassRects(Count: Integer; Rects: PRectArray); cdecl;

(you can also use another calling convention like __stdcall / stdcall, it just 
has to be the same one)

Receive the rects like this:

procedure PassRects(Count: Integer; Rects: PRectArray);
var
   I: Integer;
begin
   for I := 0 to Count - 1 do begin
     DoSomethingWith(Rects^[I]);
   end;
end;

DoSomethingWidth might copy the rects to a dynamic array or a list etc., just 
make sure you don't use the pointer after the receiver procedure returns.

-- 
Jens Gruschel
http://www.pegtop.net
0
Jens
3/12/2010 8:40:24 PM
> {quote:title=Jens Gruschel wrote:}{quote}
> >   Does anyone know how is the correct way to send an array of Rect from C++ (dll) to the delphi ? I'm using callbacks to receive the information.
> 
> assuming you have an array of Rect and the number of elements as an int, you can 
> use following function on the caller side:
> 
> void __cdecl PassRects(int count, Rect* rects)
> 
> You can call it like this:
> 
> Rect rects[10];
> rects[0] = ...
> ...
> rects[9] = ...
> PassRects(10, rects);
> 
> On the receiver side use following function:
> 
> type
>    TRectArray = array[0..$7FFFFFF] of TRect;
>    PRectArray = ^TRectArray;
> 
> procedure PassRects(Count: Integer; Rects: PRectArray); cdecl;
> 
> (you can also use another calling convention like __stdcall / stdcall, it just 
> has to be the same one)
> 
> Receive the rects like this:
> 
> procedure PassRects(Count: Integer; Rects: PRectArray);
> var
>    I: Integer;
> begin
>    for I := 0 to Count - 1 do begin
>      DoSomethingWith(Rects^[I]);
>    end;
> end;
> 
> DoSomethingWidth might copy the rects to a dynamic array or a list etc., just 
> make sure you don't use the pointer after the receiver procedure returns.
> 
> -- 
> Jens Gruschel
> http://www.pegtop.net

Hello!

  First of all, thank you for your reply.

  I understand what you said but just one more question. 

  If I want to send the struct bellow to delphi:

    typedef struct ObjectsInformation{

        RECT* ObjectPosition;  

    } OInformation[];

  ObjectsInformation* ObjectsPositions = new ObjectsInformation[value]; 

  
How can I receive this on delphi?

Thank you in advance,
Everton Soares Manso
0
Everton
3/17/2010 2:46:11 PM
>   If I want to send the struct bellow to delphi:
> 
>     typedef struct ObjectsInformation{
> 
>         RECT* ObjectPosition;  
> 
>     } OInformation[];
> 
>   ObjectsInformation* ObjectsPositions = new ObjectsInformation[value]; 
> 
>   
> How can I receive this on delphi?

It's basically the same. Replace TRect with TObjectsInformation (or whatever the 
type is named in Delphi).

-- 
Jens Gruschel
http://www.pegtop.net
0
Jens
3/17/2010 9:52:00 PM
Reply:

Similar Artilces:

Arrays, Arrays, Arrays
I mainly come from a JScript classic ASP background and I'm liking both C#.net and JScript.net. Now I have to say... "What's happened to arrays?" They used to be so flexible and easy to use. Here are my quick questions... Am I allowed to create an array with a non specified length so that I can add to it? If not then how can I modify an array's length? Can I create an array with a named index eg myArray["apple"] = "tasty"; or is the hash table the equivalent for this now? The classic array methods and properties like pop(), push(), length etc... are ...

How to unshift to an array in an array of arrays?
How to unshift to an array in an array of arrays? > -----Original Message----- > From: Angerstein [mailto:ang@nmc-m.dtag.de] > Sent: Wednesday, August 28, 2002 6:12 AM > To: beginners@perl.org > Subject: How to unshift to an array in an array of arrays? > > > How to unshift to an array in an array of arrays? $ perl -d -e 1 ..... DB<1> @aoa = ([qw(foo bar baz)]) << create array of arrays DB<2> x @aoa 0 ARRAY(0x80f82dc) 0 'foo' 1 'bar' 2 'baz' DB<3> unshift @{$aoa[0]}, 'qu...

referring to an array in an array of arrays
How can I get at an array in an array of arrays? I'm creating the arrays using: $fComments[$i++] = [ @comments ]; Now I want to get back what I put in: print "$fComments[0]\n"; but this prints ARRAY(0x107671f0). How do I follow that pointer? (I really think we need a pre-beginners list... =) TIA. - B You can try something like this: print "@{$fComments[0]}\n"; Which will attempt to dereference the array at $fComments[0]. -----Original Message----- From: Bryan R Harris [mailto:Bryan_R_Harris@raytheon.com] Sent: Tue...

Concatenating arrays from arrays of arrays
Hello - I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. The data is to be read in from a file rather than existing as literals in my code. Everything I try either crashes the computer or gives me an array of arrays instead of a flat list. I have been programming in Unicon which has a concatenate operator, but Perl makes very heavy weather of nested list management. Should I switch to Lisp, or is there a way of doing what I want to do in Perl? Regards _John Sampson_ On...

array of arrays
Hi. =20 Im using a multidimensional array in the following way: $array[$i][$j][$k] =3D [ @list ]; where, @list is a 2-D array ie. = $list[][]. How do I access the individual elements of the array @list once Ive put it = into the array @array? Thanks. -ty On Thu, Oct 18, 2001 at 02:28:41PM -0600, Tyler Cruickshank wrote: > $array[$i][$j][$k] = [ @list ]; where, @list is a 2-D array ie. $list[][]. > > How do I access the individual elements of the array @list once Ive put it > into the array @array? $array[$i][$j][$k][$l][$m] eq $list[$l][$m] Howev...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the PB structure to Oracle. Anyone has any suggestions? Thanks, Anil PB 11 or 12 I believe will have this native. <Anil> wrote in message news:422789a4.721c.1681692777@sybase.com... > Hi, > > I am looking for a way to create an array of ar...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the structure to Oracle. Anyone has any suggestions? Thanks, Anil Please don't cross-post. On 3 Mar 2005 14:02:47 -0800, Anil wrote: >Hi, > >I am looking for a way to create an array of arrays which >needs to be passed to Oracle database t...

array of arrays
Hi, I have a simple question: how do I access an array in an array? @array = (@array1, array2); ### unless this is wrong... the idea behind it is, that I have a long list, and want to put all 25 entries in a seperate array in that big array. later on I want to be able to read one specific array at a certain position... -- cheers alex mailto:Keex@gmx.de you need to learn about references. read the: perldoc perllol here is the jist though. @all = (\@array1, \@array2 ... ); # ... so on to access first array and first element...

An array of arrays
Could anybody help me out here? Here's the message I just got from a guy I know: ----------- I was wondering if you know how to create and access an array of arrays in Perl. Basically I'm parsing an exported text file containing e-mails and I think I want to move some fields into arrays until I'm ready to do my report. Here basically is what I'm looking at doing: ^ | | Array 1 (messages) | | v <------ Array 2 -------> (message fields:FROM, TO, CC, etc, sensitivity, etc) I want to be able to search through the first array to count how many messag...

Array of Array.
How is possible to declare a DYNAMIC array of array ? I need something like a dynamic hash table whose pages grow up dynamically too (each one can have different number of elements). In other words, a matrix that can be dynamic in both dimension. example: [1,2,3...] [3,4..] [5] [6,7,8,9...] [.] .. .. .. Have you considered using a DataStore? -- <hopethishelps/> Roy Kiesler [TeamSybase] SDN CodeXchange -- http://codexchange.sybase.com "Marco Meoni - News" <mmeoni@usl4.toscana.it> wrote in message news:401ba036$1@forums-2-dub... > How ...

Overloading array properties in Delphi/Win32!
Looking for something unrelated I found an article on The Delphi Geek from 2007 Default array properties - There Can Be Only One. Not! I followed the link to GoogleGroups and after registering was told "It doesn't look like you have been invited to read this blog. If you think this is a mistake, you might want to contact the blog author and request an invitation." with no way to find out who to contact. This looks like something I could use. Anyone enlighten me? Roy Lambert try here instead http://delphidicas.blogspot.com/2008/08/overloading-array-propertie...

Array of arrays
Hi I'm trying to return from a web service a array of arrays, one of the arrays is a array of objects, which I tested separately and it's working fine, and another array of integer and another of strings. When I run the web service I got this:You must implement a default accessor on System.Array because it inherits from ICollectionDefault accessor what that means? Thank you very much.  As Heinlein said "specialization is for insects" explore beyond the universe. Could you pls post the relevant code ? hi rushan thank you for the reply the code is here:  ...

[@array] and \@array
Given the case, my @array = (1,2,3,4); my $var1 = [@array]; my $var2 = \@array; What's the difference between $var1 and $var2? Are they all refered to @array? Thanks guys. On 3/22/07, Jm lists <practicalperl@gmail.com> wrote: > Given the case, > > my @array = (1,2,3,4); > my $var1 = [@array]; > my $var2 = \@array; > > What's the difference between $var1 and $var2? > Are they all refered to @array? > Thanks guys. $var2 is a reference to @array. $var1 is a reference to new array. Observe #!/usr/bin/perl use strict; use war...

Passing array from delphi app to C++ dll
Hi I need to develop a C++ DLL to use with my Delphi application (The DLL must be in C++ because we are going to use a lot of objects from OpenCV library). In my DLL I need to create a routine that will receive an array of the following delphi record: TMyRecord = record Origin: HRGN; Destination: HRGN; end; I have an array of this record type: var MyArray: array of TMyRecord; begin SetLength(MyArray, 4); // Fill the array .. .. // Pass the data to my dll function MyCPPDll(MyArray, 4); end; This is how it should work, I need to pass My...

Web resources about - C++ Array of Rect to Delphi Array of Rects - embarcadero.delphi.win32

Delphi - Wikipedia, the free encyclopedia
... an archaeological site and a modern town in Greece on the south-western spur of Mount Parnassus in the valley of Phocis . The site of Delphi ...

Delphi Automotive (@DelphiAuto) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Delphi Automotive @ DelphiAuto ...

Delphi Connect for Verizon on the App Store on iTunes
Get Delphi Connect for Verizon on the App Store. See screenshots and ratings, and read customer reviews.


Audi working with Delphi to develop autonomous car tech
Audi is developing an iPad-sized device that will pack all the necessary computing power for a self-driving car

US approves China company's acquisition of Delphi biz
The Committee on Foreign Investment in the United States has formally approved the acquisition of Delphi's global production of braking systems ...

Verizon And Delphi Officially Launch Vehicle Diagnostics Service - $250 For The Module, $5 A Month On ...
If you're a car nut, a paranoid parent, or a small business owner looking to do a little, uh, company vehicle economy analysis, Verizon's teamed ...

Watch out Google: Delphi gives Ars a ride in its self-driving car
The automotive components maker gave Ars a preview ride around the neighborhood. MOUNTAIN VIEW, CA—On Thursday morning I met with Delphi at its ...

The skinny on Delphi's autonomous road trip across the United States
Filed under: Green , Videos , Autonomous Last week, Delphi's autonomous car became the first to complete a coast-to-coast trip across the United ...

Delphi partners with WiTricity on automated wireless charging system
One could easily argue that parking between the white lines at any local hangout presents a challenge for some inexperienced drivers. So, why ...

Resources last updated: 1/12/2016 3:42:03 AM