

Example: Calling PowerBuilder functions
In
this code fragment, the class and method ID returned by calls to
the IPB_Session GetClass and GetMethodID methods
are used to initialize a PBCallInfo structure, called ci,
using the IPB_Session InitCallInfo method.
After a new pbstring variable is created,
the value of that string is set to the value of the first argument
in the PBCallInfo structure.
BOOL CALLBACK CFontEnumerator::EnumFontProc
(
LPLOGFONT lplf,
LPNEWTEXTMETRIC lpntm,
DWORD FontType,
LPVOID userData
)
{
UserData* ud = (UserData*)userData;
pbclass clz = ud->session->GetClass(ud->object);
pbmethodID mid = ud->session->GetMethodID
(clz, "onnewfont", PBRT_EVENT, "IS");
PBCallInfo ci;
ud->session->InitCallInfo(clz, mid, &ci);
// create a new string variable and set its value
// to the value in the first argument in the
// PBCallInfo structure
pbstring str = ud->session->NewString
(lplf->lfFaceName);
ci.pArgs->GetAt(0)->SetString(str);
ud->session->TriggerEvent(ud->object, mid, &ci);
pbint ret = ci.returnValue->GetInt();
ud->session->FreeCallInfo(&ci);
return ret == 1 ? TRUE : FALSE;
}