Jump to content

DllStructCreate and rect struct


Recommended Posts

Hello!

I'm having some problems translating a struct declared in delphi to autoit:

AVI_STREAM_INFO = packed record
      fccType : DWORD;
      fccHandler : DWORD;
      dwFlags : DWORD;
      dwCaps : DWORD;
      wPriority : word;
      wLanguage : word;
      dwScale : DWORD;
      dwRate : DWORD;
      dwStart : DWORD;
      dwLength : DWORD;
      dwInitialFrames : DWORD;
      dwSuggestedBufferSize : DWORD;
      dwQuality : DWORD;
      dwSampleSize : DWORD;
      rcFrame : TRect;
      dwEditCount  : DWORD;
      dwFormatChangeCount : DWORD;
      szName : array [0..63] of char;
  end;

As you can see it's not very advanced and mostly it's just a whole bunch of dwords :D

But then I come to rcFrame which is supposed to be a TRect.

TRect seems to be a the delphi equivalence of a regular rect struct (int x1, int y1, int x2, int y2)

But even if I create a rect struct, how would I use it in my other struct?

Anyways any ideas?

Thanks!

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Will this work?

$trect = DllStructCreate("int x1; int y1; int x2; int y2")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$str = "DWORD fccType;"
$str&= "DWORD fccHandler;"
$str&= "DWORD dwFlags;"
$str&= "DWORD dwCaps;"
$str&= "word wPriority;"
$str&= "word wLanguage;"
$str&= "DWORD dwScale;"
$str&= "DWORD dwRate;"
$str&= "DWORD dwStart;"
$str&= "DWORD dwLength;"
$str&= "DWORD dwInitialFrames;"
$str&= "DWORD dwSuggestedBufferSize;"
$str&= "DWORD dwQuality;"
$str&= "DWORD dwSampleSize;"
$str&= $trect & " rcFrame;"
$str&= "DWORD dwEditCount;"
$str&= "DWORD dwFormatChangeCount;"
$str&= "var[64] szName;"

$struct2 = DllStructCreate($str)
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
Link to comment
Share on other sites

Will this work?

$trect = DllStructCreate("int x1; int y1; int x2; int y2")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$str = "DWORD fccType;"
$str&= "DWORD fccHandler;"
$str&= "DWORD dwFlags;"
$str&= "DWORD dwCaps;"
$str&= "word wPriority;"
$str&= "word wLanguage;"
$str&= "DWORD dwScale;"
$str&= "DWORD dwRate;"
$str&= "DWORD dwStart;"
$str&= "DWORD dwLength;"
$str&= "DWORD dwInitialFrames;"
$str&= "DWORD dwSuggestedBufferSize;"
$str&= "DWORD dwQuality;"
$str&= "DWORD dwSampleSize;"
$str&= $trect & " rcFrame;"
$str&= "DWORD dwEditCount;"
$str&= "DWORD dwFormatChangeCount;"
$str&= "var[64] szName;"

$struct2 = DllStructCreate($str)
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
Nope :D

@error = 2 Element value out of range.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I'm not very proficient with this dll stuff...I also can't find much about nested structs. I'm not even sure AutoIt can handle this type of thing due to the lack of OOP.

$trect = DllStructCreate("int x1; int y1; int x2; int y2")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$str = "DWORD fccType;"
$str&= "DWORD fccHandler;"
$str&= "DWORD dwFlags;"
$str&= "DWORD dwCaps;"
$str&= "word wPriority;"
$str&= "word wLanguage;"
$str&= "DWORD dwScale;"
$str&= "DWORD dwRate;"
$str&= "DWORD dwStart;"
$str&= "DWORD dwLength;"
$str&= "DWORD dwInitialFrames;"
$str&= "DWORD dwSuggestedBufferSize;"
$str&= "DWORD dwQuality;"
$str&= "DWORD dwSampleSize;"
$str&= "ptr " & DllStructGetPtr($trect) & ";"
$str&= "DWORD dwEditCount;"
$str&= "DWORD dwFormatChangeCount;"
$str&= "var[64] szName;"

$struct2 = DllStructCreate($str)
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
Edited by weaponx
Link to comment
Share on other sites

I'm not very proficient with this dll stuff...I also can't find mutch about nested structs.

$trect = DllStructCreate("int x1; int y1; int x2; int y2")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$str = "DWORD fccType;"
$str&= "DWORD fccHandler;"
$str&= "DWORD dwFlags;"
$str&= "DWORD dwCaps;"
$str&= "word wPriority;"
$str&= "word wLanguage;"
$str&= "DWORD dwScale;"
$str&= "DWORD dwRate;"
$str&= "DWORD dwStart;"
$str&= "DWORD dwLength;"
$str&= "DWORD dwInitialFrames;"
$str&= "DWORD dwSuggestedBufferSize;"
$str&= "DWORD dwQuality;"
$str&= "DWORD dwSampleSize;"
$str&= "ptr " & DllStructGetPtr($trect) & ";"
$str&= "DWORD dwEditCount;"
$str&= "DWORD dwFormatChangeCount;"
$str&= "var[64] szName;"

$struct2 = DllStructCreate($str)
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
Still @error=2 :D

Hope Siao will pop in and clear up the situation, he's really good at this :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Rect as part of another structure is just the same as Rect alone. 4 ints in a row.

If you want, you can group them into

int Rect[4]

If you still need examples, take a look at files in Include folder. It has to be used there quite a lot.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Rect as part of another structure is just the same as Rect alone. 4 ints in a row.

If you want, you can group them into

int Rect[4]

If you still need examples, take a look at files in Include folder. It has to be used there quite a lot.

Thanks Siao for clearing up the situation :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...