I'm trying to create a visual PBNI object that will ultimately, I hope, allow me to subclass a window. Everything seems ok on the surface until I try to trigger a custom event on the object.
Then the application crashes.
The code fragment that defines the call (returned by PBX_GetDescription) is:
_T("class u_x_subclasser from userobject\n") \ _T(" subroutine uf_start(unsignedlong wndhandle, unsignedlong msgid)\n") \ _T(" subroutine uf_end()\n") \ _T(" event long windowprocmessage(unsignedlong hwnd, unsignedlong msg, unsignedlong wparam, unsignedlong lparam, ref boolean callbase)\n") \ _T("end class\n") \
Note I'm defining an event called called windowprocmessage. If I leave out the part that tries to fire this event and import into Powerbuilder then I see the object with the defined methods and the event and it all looks ok and I can call the methods with no problem.
But as soon as I introduce the following code then I get the crash:
pbclass thisClass = m_pSession->GetClass(m_pbobject); pbmethodID mid = m_pSession->GetMethodID(thisClass, _T("windowprocmessage"), PBRT_EVENT, _T("LUUUURB")); if (mid != kUndefinedMethodID) { try { PBCallInfo ci; m_pSession->InitCallInfo(thisClass, mid, &ci); ci.pArgs->GetAt(0)->SetLong((pblong)hwnd); ci.pArgs->GetAt(1)->SetUlong(uMsg); ci.pArgs->GetAt(2)->SetUlong(wParam); ci.pArgs->GetAt(3)->SetUlong(lParam); ci.pArgs->GetAt(4)->SetBool(*callbase); //**** THIS NEXT LINE CRASHES! PBXRESULT pbx_res = m_pSession->TriggerEvent(m_pbobject, mid, &ci); // Was PB exception thrown? if (m_pSession->HasExceptionThrown()) { // Handle PB exception m_pSession->ClearException(); } *callbase = ci.pArgs->GetAt(4)->GetBool()? true:false; // Strange syntax but avoids pbboolean to bool conversion warning returnVal = ci.returnValue->GetLong(); m_pSession->FreeCallInfo(&ci); } }
Any ideas?