Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Active-X created in C++ to expose a C library
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00902136
Message ID:
00922640
Vues:
12
Finally got this fixed w/ help from MS. You were right it was a need for using ::postmessage, but what I didn't understand was how to create the window and link it to the main thread... Good old MSDN subscription !

Thanks again for your help in the initial diagnosis...




>Hmm.. The answer may be you using a single threaded control. Always use Apartment threading model for best results. A single threaded control can cause many memory crashes and problems with modern programming languages.
>
>>Brian, I hate to keep bothering you but can I ask another quick question ?
>>
>>I tried everything I can think of and VFP never sees the event ever....
>>
>>So I decided to make sure that VFP could see the events in a simple single threaded ocx written with the MFC ActiveX Control Wizard. I created a brand new C++ Active X Control Project with only 2 propertys and 1 event and in the OnChange of one of the properies the event is fired but again vfp never sees the event firing ??? Does this make any sense to you ? On a form the event never fires but I can read and write the properties of the control.... But if I try to instantiate in code I can't even read or write props as the control sends a "Catastrophic Failure" OLE error ?
>>
>>If I try this code:
>>
>>
>>
>>Public oMyObj
>>
>>oMyObj = Crea("VFPTEST.VfpTestCtrl.1")
>>Vfpocxx=Newobject("myclass")
>>
>>Eventhandler(oMyObj,Vfpocxx)
>>
>>oMyObj.firstName = "Greg"    * <-- This line provokes a "Catastrophic Failure"
>>
>>oMyForm = Crea("myForm")
>>oMyForm.Show()
>>
>>
>>x=NEWOBJECT("myclass")
>>
>>DEFINE CLASS myclass AS session OLEPUBLIC
>>
>>	IMPLEMENTS _DVfpTestEvents IN "Z:\MIS\C++\VFPTEST\DEBUG\VFPTEST.OCX"
>>
>>	PROCEDURE _DVfpTestEvents_mitaiEvent() AS VOID
>>	* add user code here
>>	ENDPROC
>>
>>	PROCEDURE _DVfpTestEvents_Click() AS VOID
>>	* add user code here
>>	ENDPROC
>>
>>	PROCEDURE _DVfpTestEvents_myClickIn(xPos AS Number, yPos AS Number) AS VOID
>>	* add user code here
>>	ENDPROC
>>
>>ENDDEFINE
>>
>>
>>Define Class myForm As Form
>>	WindowType = 1
>>	AutoCenter = .T.
>>
>>Enddefine
>>
>>
>>
>>Accessing any of the properties gives this "Catastrophic Failure" error but only when instantiated in code. BTW it does the same thing even if Eventhandler() is not used...
>>
>>Does this mean anything to you ???
>>
>>Thanks
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>>>I had to leave this project alone for a while but am now back on it...
>>>>
>>>>How would I send a message to the ActiveX's window if its derived from cOleControl and has no window handle property ?
>>>>
>>>>Thanks !!!
>>>>
>>>>
>>>>
>>>>>Override the message handler for the ActiveX's window. Post a custom message to the handler using SendMessage to the handle this->m_hWnd
>>>>>
>>>>>I would love to help more but the implementation can be rather extensive.
>>>
>>>Create a class derived from Cwnd. have a member variable of that class the same as your control. Set the pointer of your control to the member variable. Now that window class can call your events.
>>>
>>>Now, create a member variable of that class in your control. Create the window at construction. Then pass the handle to the window to other threads. They post a message which in turn is handled by your windows class which then fires the events on your control via the pointer in which you set earlier.
>>>
>>>It is rather confusing and complicated until you know it. Then it seems rather silly and simple. Still confusing. But simpler.
>>>
>>>Good luck. Hopefully this helps you. It is about as good as i can get with the time i have.
Greg Foote
Software At Work, Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform