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.

AppGameKit Classic Chat / [Plugin] Library - Call DLL functions directily from Teir 1

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jun 2017 06:21 Edited at: 24th Jun 2017 10:00
Not sure how useful this would be I just fancied the challenge of making it work

This plugin will enable you to call functions in dynamic link library's directly from Tier 1 code (windows only) without needing them formatted as a plugin, it currently only supports functions with up to 5 arguments but I can expand this to support upto 20 arguments, it also only supports string and integer argument types and integer returns, this is a limitation of PureBasic but I think I can code a work-a-round, I might be able to support string returns depends on the demand but for now I'm pretty happy it works as there's many library's out there that could be useful even with the limitations.

Edit: Now supports 20 max arguments and string returns via memory buffer
Added functions:
Library.Alloc()
Library.DeAlloc()
Library.Peek()

Example using GetClassNameA



heres a few basic usage examples
// show a message box
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx


// play a beep sound
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx


// play a message beep
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680356(v=vs.85).aspx


// show shell about dialog
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb762152(v=vs.85).aspx


if anyone finds it useful let me know and I'll expand the function set, I don't own any DBPro dll's but I'm curious to know if this system will help support them, anyone want to colab?, are they even compatible?

Attachments

Login to view attachments
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Jun 2017 08:06 Edited at: 24th Jun 2017 08:57
Heres a full MessageBox example showing how to use API flags with icons and return values



Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 9th Aug 2017 18:06
Hi PartTimeCoder! Would your library plugin be able to call the color picker in windows? If so, would you pretty please post a snippet doing this? I'm not quite clever enough to figure out if or how to do this.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 9th Aug 2017 19:37
the ChooseColor() function expects a pointer to a CHOOSECOLOR structure and fills the structure based on the users selection and this is used inplace of a return value, altho it is possible to this by assigning the memory I don't really know how to do it this way, this library plugin was a "see if it could be done" project and although it works its a little restrictive, it has no direct access to structure data

As luck would have it I have a plugin I am using where I have used ChooseColor() but added in proper custom color selection, you know when you set a custom color, open the dialog again and the colors are all reset, well my implementation saves the color set to ini file ready for use next time round even after the application has been restarted.

the code is very heavily embedded in a private plugin I am using for a project but give me an hour or 2 and I'll export the code to a separate plugin.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 9th Aug 2017 20:47
I thought rather than just have a single function plugin that I would add some more dialog types to this

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 9th Aug 2017 23:27 Edited at: 9th Aug 2017 23:30
Wow, those will be REALLY useful!

One thing, when I run the code snippet, I get an error "AppGameKit window not registered!"

Any advice?

EDIT: Never mind, I didn't have the window named correctly. Thanks so much for your efforts and willingness to share!

Rich
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 25th Aug 2017 10:05
Hi

It's very interesting.

I have tried the dialog, and it doesn't work properly.

it's ok for :


But for :


The application doesn't respond and crash.
it seems:

doesn't work properly.
When I comment this line, it's ok.

Do you know if we can add some gadgets and menu in agk ?
it would be awesome
AGK2 tier1 - http://www.dracaena-studio.com
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 25th Aug 2017 13:04
Funny thing I tested it before posting and it worked fine but yes its crashing here too, I'll open it up and take a look a bit later.

Quote: "Do you know if we can add some gadgets and menu in agk ?"


not directly, AppGameKit wants to draw over the top of them, you can however build a UI in PB and embed AppGameKit into it

first you create a plugin function that sends in the title of the agk window, in your UI have a container host for agk, and use the below code to embed it.

(this is pulled directly from my 3D editor)


AGK now becomes part of your UI, use the plugin system to send events and create functions to add/remove gadget items, be warned, do not try and make AppGameKit handle complete UI creation by wrapping PB's functions, A. its against the PB EULA and B. it will crash, PB is fast, use that to your advantage and do as much work in the PB side as you can this will make it 100% more stable and keep your FPS nice n high

for example, use a SendMessage type system, so a single plugin function can have multiple uses and the heavy lifting of a huge select statement is done in PB and AppGameKit in not loading 100's of plugin functions on startup, you just need agk to 'ask' the UI what event just happened..... a lot of trial n error got me this far and my system seems pretty stable now I ironed out the bugs.

I'll get that plugin looked at soon, dont like bugs! lol






Login to post a reply

Server time is: 2024-03-19 04:27:04
Your offset time is: 2024-03-19 04:27:04