Theos PowerBasic Museum 2017

General Category => General Discussion => Topic started by: David Marco on May 13, 2009, 05:38:10 AM

Title: Calling a VB function from a DLL
Post by: David Marco on May 13, 2009, 05:38:10 AM
Hi all,

I'm trying to create a powerbasic DLL in order to be used with VB6.
Dll has a dialog with a callback function. All messages are intercepted with this function.
All works fine.
Now, I need let VB programmer define some functions that will be launched when some events are detected (like double click or right click).

I tryed something like this:



#COMPILE DLL "call.dll"
#DIM ALL
#INCLUDE "WIN32API.INC"

GLOBAL nbPlayAction AS DWORD

' main entry point
DECLARE FUNCTION f_start ALIAS "f_start" (a AS LONG) AS LONG

DECLARE SUB PlayActionProcType (BYREF s AS ASCIIZ)

SUB PlayScript(BYVAL Script$)
    CALL DWORD nbPlayAction USING PlayActionProcType(BYCOPY Script$)
END SUB

FUNCTION f_start alias "f_start" (a AS LONG) EXPORT AS LONG
LOCAL sfunction AS ASCIIZ * 64
sfunction = "call vb_function"
playscript sfunction
FUNCTION = 1
END FUNCTION


But nothing appairs correct.
Could any tell me the correct way ?

Thanks in advance,
David Marco
Title: Re: Calling a VB function from a DLL
Post by: Frederick J. Harris on May 14, 2009, 02:36:56 AM
Quote
I need let VB programmer define some functions that will be launched when some events are detected (like double click or right click).

In other words, events are occurring within windows (Dialogs) created within the Dll and are being captured there within your callbacks (Window Procedure), and you need to make these events visible within the Visual Basic client so that procedures can be created there to handle them?  If that's the case the general procedure involved is to define custom messages in the form of equates that will be defined both in the client (VB App) and your PowerBASIC Dll.  When the event is detected within the dll, the message is SendMessag()'ed back to the client (VB) in the form of a WM_NOTIFY message.  Its late here now and I've got to get some rest, but if this is what you need I may be able to help tomorrow.

Fred