GetMethodID

PowerBuilder Native Interface

IPB_Session interface:

GetMethodID method

Description

Returns the ID of the requested method.

Syntax

GetMethodID(pbclass cls, LPCTSTR methodName, PBRoutineType rt, LPCTSTR signature, pbboolean publicOnly)

Argument

Description

cls

pbclass containing the function.

methodName

The string name of the method in lowercase.

rt

Type of the method: PBRT_FUNCTION for function or PBRT_EVENT for event.

signature

Internal signature of the PowerBuilder function, used to identify polymorphic methods in one class. Obtained with the pbsig125 tool. If the signature is a null string (" "), the first method found with the name methodName is returned.

publicOnly

A boolean that determines whether only public methods are searched (true) or all methods are searched (false). The default is true.

Return Values

pbMethodID of the method or kUndefinedMethodID on error.

Examples

This function uses GetMethodID to obtain the identifier (mid) of the onnewfont function so that the identifier can be used to initialize the PBCallInfo structure and call the function:

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);
   pbstring str = ud->session->
      NewString(lplf->lfFaceName);
   ci.pArgs->GetAt(0)->SetPBString(str);
   ud->session->TriggerEvent(ud->object, mid, &ci);
   pbint ret = ci.returnValue->GetInt();
   ud->session->FreeCallInfo(&ci);

   return ret == 1 ? TRUE : FALSE;
}

Usage

The GetMethodID function is used to obtain the ID of a method so you can use it to invoke functions and trigger events.

See Also