Since Python Win32 lib does not implement DDE Advise Loop and i need it
for a project, i guessed that Boost Python would be a way to integrate
the ddeml lib with my python code. I guessed i could just call
call_method inside the DDE Callback function, but when i do that python
crashes. I can't(or couldnt find how to) add the DDE Callback function
to the Python Module and i tried through a 2 stages call(DdeCallback
calls a Python Module function that call_method) without success.
Everything else works great... I can connect to the DDE Server, the
advise loop works, my setPyCallback/getPyCallback works... I just can't
get any python to work on the C++ DDECallback function.<br>
<br>Here is part of the code<br>------------------<br><br>PyObject* myPythonCallback;<br>void CallPy(TCHAR SomeValue){<br>    boost::python::call&lt;void&gt;(<div id=":193" class="ii gt">myPythonCallback,SomeValue);<br>}<br>

HDDEDATA CALLBACK DdeCallback(UINT wType,UINT uFmt,HCONV hconv,HSZ hsz1,HSZ hsz2,HDDEDATA hData,DWORD dwData1,DWORD dwData2){<br>
..........<br>    switch (wType) {<br>            case XTYP_ADVDATA:<br>                        .................. bunch of code ..........<br>                        CallPy(mybuffer);<br>                        return((HDDEDATA)DDE_FACK);<br>


}<br>int ddeConnect();<br><br>void ddeAdvise(TCHAR* topic);<br><br>void setCallback(PyObject* p){<br>    boost::python::call&lt;void&gt;(p,&quot;3&quot;);// test calling function and WORKS<br>    myPythonCallback = p;<br>

}<br><br>BOOST_PYTHON_MODULE(extending)<br>
{<br>    using namespace boost::python;<br>    def(&quot;ddeConnect&quot;, ddeConnect);<br>    def(&quot;ddeAdvise&quot;, ddeAdvise);<br>    def(&quot;ddeSetCallback&quot;, setCallback);<br>    def(&quot;CallPy&quot;, CallPy);<br>


}<br><br>-------------<br><br>Python<br>------------<br>import extending<br>import wx<br>import justAFrame<br><br>def mCB (valor):<br>    print &quot;mCB&quot;,str(valor)<br>    return float(str(valor))<br><br>class MyFrame(justAFrame.MyFrame):<br>


    def initAfter (self):<br>        justAFrame.MyFrame.initAfter(self)<br>        extending.ddeConnect()<br>        extending.ddeSetCallback(mCB)<br>        extending.CallPy(&quot;1&quot;) #WORKS<br>
        extending.ddeAdvise(&quot;0012PETR4;1&quot;)<br><br>app = wx.PySimpleApp()<br>frame=MyFrame(None,title=&quot;DDE Test&quot;)<br>app.MainLoop()<br>--------------<br><br><br>How
can i make this DdeCallback to interact with a python function defined
by the user ? Is there a better way to do this ? I&#39;m open to
suggestions.</div>