Step 5: Export methods to create class instances

PowerBuilder Native Interface

Step 5: Export methods to create class instances

  • For visual classes, the instance is created when the window or visual control in which the class is used is opened. See "Creating visual class instances".

  • For nonvisual classes, the instance is created when the PowerBuilder CREATE statement is used. This is described next.

PBXEXPORT PBXRESULT PBXCALL PBX_CreateNonVisualObject(
   IPB_Session * session,
   pbobject obj,
   LPCSTR className,
   IPBX_NonVisualObject **nvobj
)
{
   PBXRESULT result = PBX_OK;
   // The class name must not contain uppercase
   if ( strcmp( className, "classone" ) == 0 )
      *nvobj = new ClassOne;
   else if ( strcmp( className, "classtwo" ) == 0 )
      *nvobj = new ClassTwo( session );
   else if ( strcmp( className, "classthree" ) == 0 )
      *nvobj = new ClassThree;
   else
   {
      *nvobj = NULL;
      result = PBX_E_NO_SUCH_CLASS;
   }
   return PBX_OK;
};