• Welcome to Theos PowerBasic Museum 2017.

Calling a VB function from a DLL

Started by David Marco, May 13, 2009, 05:38:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

David Marco

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

Frederick J. Harris

#1
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