Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Passing UDT's to Win32 DLL Calls (DBP v6.0)

Author
Message
CodemanV
19
Years of Service
User Offline
Joined: 25th Aug 2005
Location: South Wales Valleys, UK
Posted: 4th May 2006 04:26 Edited at: 4th May 2006 05:40
Hello

Spooky just inspired me to actually post something but I do think it's about time I started putting some code up on these 'ere forums as they have helped me a lot in my quest to master DBP (I'm still a beginner but I've just finished level 3 of the quest )

A "bug" in DBP allows you to get the pointer of a UDT array. This allows you to create a UDT and fill the UDT variables with just one call to a Win32 function - sort of C++ish.

The following code is a basic demonstration of how it works. I hope the comments are clear enough for you.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th May 2006 08:03
very cool. I dont understand the part with the queue commands.

So this will work as long as the UDT matches the exact structure the windows call looks for?


CodemanV
19
Years of Service
User Offline
Joined: 25th Aug 2005
Location: South Wales Valleys, UK
Posted: 4th May 2006 08:43 Edited at: 4th May 2006 08:48
Cheers Phaelax

Notice in the above snippet that when the Pnt() and Rect() arrays are dimmed, there are no dimensions allocated, the arrays are initially empty.

In the example, the <ADD TO QUEUE> command was used for the 2 following reasons,

1 - the command creates element zero.
2 - the internal array pointers are automatically set to the element index number they create, in this case element zero.

This allows you to just type the array name without an index number in the bracket and the current array element will be accessed.

e.g.


You could also do it this way



I have also been experimenting with the Array commands for dynamically increasing and shrinking arrays and lists so I'm used to using them now.

Quote: "So this will work as long as the UDT matches the exact structure the windows call looks for?"


As far as I know, yes, that should be the case. I've only done some basic stuff so far.

One possible flaw maybe if a C++ type structure contains other C++ structures, this could happen with DLL function calls with more complex parameters such as Window styles, callbacks, etc.

e.g.


Although, thinking about it, as long as the C++ structures are strictly adhered to and the DLL calls are executed correctly , there shouldn't be a problem.

Hope my explanations are clear, even though I know what I mean, I might not convey the info as clearly as I think I have.

I should be posting some other memory stuff later, more graphics based though. I just want to make sure that there are no silly bugs in the code before I post it.

Login to post a reply

Server time is: 2024-11-23 07:25:10
Your offset time is: 2024-11-23 07:25:10