I wrote a multithreaded OCX (Visual C++, with the ocx wizzard).
In a second thread (buffer processing) I fire an event to tell the application that someting has to be processed. The application then call's a property, set by the OCX before firing the event.
A Visual C++ application test programm gets the correct values and runs perfect. However, a VB programm crashes when asking the property in the eventhandling. (It does not crash when it asks the property value outside the event-handling!!)
Here's some OCX code :
- creation of the second thread
- the second thread
UINT BufferThread (LPVOID pParam)
CPosKeyboardCtrl* pObject = (CPosKeyboardCtrl*)pParam;
if (pObject == NULL ||
return 1; // if pObject is not valid // do something with 'pObject'
// wait until character is received
while (pVerwerkBuffer < pCurrentBuffer)
// we have characters to process
pObject->m_pOSKeyData = TheKey;
pVerwerkBuffer = pBeginGlobalBuffer;
pCurrentBuffer = pBeginGlobalBuffer;
I am desperate. Why does the C++ testprogramm work, but not a VB programm?
A correct and usable answer please.