I know that.
The cb may not be invoked from inside the pb thread, that's all.
The cb may not be invoked from inside the pb thread, that's all.
'PB FUNCTION GetThreadCount EXPORT AS LONG 'VB uses to not end until threadcount = 1 FUNCTION = THREADCOUNT END FUNCTION 'VB Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If GETTHREADCOUNT > 1 Then Splash "Background function is processing", 1000 Cancel = True ElseIf gBusy Then Splash "Processing a request", 1000 Cancel = True End If End Sub
' MY_VB_PROGRAM.BAS FUNCTION MainWindowProcedure (hWnd, uMSG, wParam, lparam) ...... hThread = CreateThread (params, calling MY_VB_FUNCTION ) ' returns immediately with a thread handle .... FUNCTION My_VB_FUNCTION (params) CALL MyFunctionInmyPBDLL (params) PostMessage primaryHWnd, private_message_no, _ params with results of MyFunctionInMyPbDLL END FUNCTION
GLOBAL gForm1 AS LONG SUB Init(Form1 AS DWORD) EXPORT gForm1 =Form1 END SUB SUB CallVb EXPORT LOCAL s AS STRING 'use STRPTR with dynamic strings LOCAL lResult AS LONG LOCAL dwHandle AS DWORD LOCAL dwMsg AS DWORD LOCAL dwParam AS DWORD LOCAL lParam AS LONG dwHandle = gForm1 dwMsg = &H300 s = "TEST COMPLETE" dwParam = LEN(s) 'length lParam = STRPTR(s) 'address lResult = SendMessage(dwHandle,dwMsg,dwParam,lParam) END SUB FUNCTION Peeker(Address AS DWORD, Characters AS LONG) EXPORT AS STRING FUNCTION = PEEK$(address???, characters) END FUNCTION
#DIM ALL #COMPILE DLL 'subDLL.bas #INCLUDE "win32api.inc" %CallBack = &H300 GLOBAL gControl AS LONG GLOBAL gPrevWndProc AS LONG SUB TestCallBack EXPORT IF gControl = 0 THEN ? "Subclass is not on":EXIT SUB STATIC Counter AS LONG LOCAL s AS STRING LOCAL wParam AS DWORD LOCAL lParam AS LONG INCR Counter s = "Callback string" + STR$(Counter) wParam = LEN(s) lParam = STRPTR(s) SendMessage gControl,%Callback,wParam,lParam 'let callback handle it END SUB SUB TestSendMessage(hControl AS LONG) EXPORT STATIC Counter AS LONG LOCAL s AS STRING INCR Counter s = "SendMessage direct to control" + STR$(counter) SendMessage(hControl,%LB_ADDSTRING,%NULL,STRPTR(s)) END SUB FUNCTION Peeker(Address AS DWORD, Characters AS LONG) EXPORT AS STRING 'Could be used by VB to read string in memory FUNCTION = PEEK$(address???, characters) END FUNCTION SUB EndSubClass() EXPORT CALL SetWindowLong(gControl, %GWL_WNDPROC, gPrevWndProc) 'restore old address END SUB FUNCTION WindowProc(BYVAL hControl AS LONG, BYVAL uMsg AS LONG, _ BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG DIM sPeekString AS STRING 'string already in memory IF uMsg = %CALLBACK THEN 'triggered callback sPeekString = PEEKER(lParam, wParam) SendMessage gControl,%LB_ADDSTRING,%NULL,STRPTR(sPeekString) EXIT FUNCTION END IF FUNCTION = CallWindowProc(gPrevWndProc, hControl, uMsg, wParam, lParam) END FUNCTION SUB StartSubClass(hControl AS LONG) EXPORT gControl = hControl gPrevWndProc = SetWindowLong(gControl, %GWL_WNDPROC, CODEPTR (WindowProc)) END SUB
#IF 0 REM VB6 REM 1. Add a Command button REM 2. Add a listbox PRIVATE DECLARE SUB TESTSENDMESSAGE LIB "subdll" (hControl AS LONG) PRIVATE DECLARE SUB TESTCALLBACK LIB "subdll" () PRIVATE DECLARE SUB STARTSUBCLASS LIB "subdll" (hControl AS LONG) PRIVATE DECLARE FUNCTION ENDSUBCLASS LIB "subdll" () AS LONG OPTION EXPLICIT PRIVATE SUB Command1_Click() TESTSENDMESSAGE List1.hWnd TESTCALLBACK END SUB PRIVATE SUB Form_Load() CHDIR App.Path Command1.Caption = "Test" STARTSUBCLASS List1.hWnd END SUB PRIVATE SUB Form_QueryUnload(CANCEL AS INTEGER, UnloadMode AS INTEGER) ENDSUBCLASS 'required if subclassing END SUB #ENDIF
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment