Reading Structure Argument

Windows specific forum
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Reading Structure Argument

Post by LuaDev »

Hi guys, here i go with another stupid question

im making a plugin for another development platform and the SDK requires that i export some functions, all is well for the most part, but.....

i have this function that passes a structure as a argument (not a pointer to the structure)

Code: Select all

EXPORT void _DrawDesign(long ClassID ,HDC hDC, HWND hMainWnd, RECT rcObRect, BOOL bVisible, BOOL bEnabled)
how on earth do i access the values of this structure ?, everything i try either fails or crashes the IDE
User avatar
IceSoft
Addict
Addict
Posts: 1616
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: Reading Structure Argument

Post by IceSoft »

Wich SDK?
Belive!
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Reading Structure Argument

Post by ts-soft »

I think:

Code: Select all

Structure rcObRect
  bla.i
  ;...
EndStructure

Define bla.rcObRect

_DrawDesign(ClassID, hDC, hMainWnd, @bla, #True, #True)

Debug bla\bla
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Reading Structure Argument

Post by LuaDev »

Wich SDK?
the SDK is for AutoPlay Media Studio, but it requires you fill a C++ class (which cant be done in PB?) so a friend of mine wrote a wrapper (or proxy) dll that fills the class by calling functions from my dll
I think:
you misunderstand, that function must be defined in my dll and the proxy dll calls the function defined in my code and sends the RECT structure, i need to access the struct to get the dimensions of the host container to draw my object

i should have explained all this first to avoid confusion
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Reading Structure Argument

Post by LuaDev »

nm, i got there in the end

Code: Select all

*ptr.RECT = @*rcObRect
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Reading Structure Argument

Post by Trond »

Are you sure you can access the last two parameters with your solution?
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Reading Structure Argument

Post by LuaDev »

no i cant, didn't try till today and got all sorts of weird problems, back to the drawing board then i guess
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: Reading Structure Argument

Post by Trond »

Maybe this works:

Code: Select all

Procedure _DrawDesign(ClassID, hDC, hMainWnd, left, top, right, bottom, bVisible, Enabled)
LuaDev
User
User
Posts: 33
Joined: Tue Feb 16, 2010 2:41 pm

Re: Reading Structure Argument

Post by LuaDev »

yea, that seems to work ok, thanks

how did that happen, was the structure expanded somehow?
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Reading Structure Argument

Post by Demivec »

LuaDev wrote:yea, that seems to work ok, thanks

how did that happen, was the structure expanded somehow?
The values of the structure are being pushed onto a parameter stack. The structure appears as a collection of (4) 4-byte integers. This would be the same as pushing 4 separate 4-byte integers. The sizes need to match properly for this to work.
Post Reply