Page 1 of 1
[PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Fri Apr 02, 2010 8:47 am
by mpz
Hi,
i use different types in StructurUnions for DX9, but this works no more. Here comes an example from the help file. Any solution for it or other kind of structure type for that ?
Code: Select all
Structure Type
Name$
StructureUnion
Long.l ; Jedes Feld (Long, Float und String) befinden sich
Float.f ; an derselben Stelle im Speicher.
String.s ;
EndStructureUnion
EndStructure
best regards,
Michael
Re: [PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Fri Apr 02, 2010 9:02 am
by Fred
Use a pointer for the string. This kind of structure could produce massive leak.
Re: [PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Fri Apr 02, 2010 9:22 am
by mpz
Hello Fred,
i have a DX8 Structure DIACTION for my IDirectInputDevice8 (for my DX9 lib with forcefeedback Joystick an so on)
Code: Select all
typedef struct _DIACTION {
UINT_PTR uAppData;
DWORD dwSemantic;
DWORD dwFlags;
union {
LPCTSTR lptszActionName;
UINT uResIdString;
};
GUID guidInstance;
DWORD dwObjID;
DWORD dwHow;
} DIACTION, *LPDIACTION;
typedef const DIACTION *LPCDIACTION;
and the PB translation was :
PB Structure
Code: Select all
Structure DIACTION
uAppData.l
dwSemantic.l
dwFlags.l
StructureUnion
*lptszActionName.l ;unicode?
uResIdString.l
EndStructureUnion
uidInstance.GUID
dwObjID.l
dwHow.l
EndStructure
but this works anymore. You say i can only use Pointer in the StructureUnion ?
How can i mak a working PB translation of the DIACTION Structure? Thanks for your help...
best regards
Michael
Re: [PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Fri Apr 02, 2010 9:28 am
by Fred
Your new structure looks correct. Use PeekS() get the string content:
Code: Select all
PeekS(YourStruct\*lptszActionName)
Re: [PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Mon Apr 12, 2010 5:57 pm
by Xombie
Does the pointer in structure thing only work in 4.50 and not 4.41?
Re: [PB4.50 x86 Beta 1] different types in StructureUnion
Posted: Mon Apr 12, 2010 11:28 pm
by Demivec
Xombie wrote:Does the pointer in structure thing only work in 4.50 and not 4.41?
No it has worked at least as far back as v4.
The example Fred gave contained a typo, it should have left off the '*' when it was used.
The '*' is used in the structure when defining it but is left off when referencing the structure element.