The wpCnrInsertObject method inserts a record into a container control window. The following shows the syntax of wpCnrInsertObject:
#define INCL_WINWORKPLACE #include <os2.h> PMINIRECORDCORE wpCnrInsertObject (WPObject *self, HWND hwndCnr, PPOINTL pIcon, PMINIRECORDCORE pParent, PRECORDINSERT pRecInsert)
The self (WPObject *) parameter is the pointer to the object on which the method is being invoked. It points to an object of class WPObject.
The hwndCnr (HWND) parameter is the handle of the container control window.
The pIcon (PPOINTL) parameter is the pointer to a POINTL structure specifying the initial icon position in the container control window.
The pParent (PMINIRECORDCORE) parameter is the pointer to the parent record. The pParent parameter specifies the record of the immediate parent of the record being inserted. This parameter should be set to NULL, if the record has no parent or if the Tree view is not supported.
The pRecInsert (PRECORDINSERT) parameter is the pointer to the RECORDINSERT structure specifying how this record is to be inserted relative to other records in the same container. The possible values of this parameter are:
Value
The rc (PMINIRECORDCORE) parameter is returned with one of the following values:
Value
This method is used to give Workplace Shell object behavior (such as context menu support) to records inserted directly into a WC_CONTAINER control window. To remove records from the container, a call to wpCnrRemoveObject should be made. The following figure shows the insertion of an object into a container control window:
/************************************************************************//* This sample code assumes that the object has already been created */ /* using wpclsNew and object's pointer has been obtained */ /* using wpclsQueryObject. */ /************************************************************************/ WPObject *self; /* The object to be inserted */ HWND hwndCnr; /* Handle of the container */ /* window */ POINTL ptlIcon; /* Location within container */ /* to place record */ RECORDINSERT RecordInsert; /* Container RECORDINSERT */ /* data structure */ /************************************************************************/ /* Set up the RECORDINSERT data structure. */ /* The object will be inserted at the beginning of the list of records. */ /************************************************************************/ RecordInsert.cb = sizeof(RECORDINSERT); /* Size of the RECORDINSERT */ /* data structure */ RecordInsert.pRecordParent = NULL; /* Insert record at root */ /* level */ RecordInsert.zOrder = CMA_TOP; /* Top of the z-order */ RecordInsert.cRecordsInsert = 1; /* Inserting 1 record */ RecordInsert.fInvalidateRecord = TRUE; /* Invalidate record at the */ /* time it is inserted */ RecordInsert.pRecordOrder = /* Place record at beginning */ (PRECORDCORE)CMA_FIRST; /* of the list of records */ /* already inserted */ /************************************************************************/ /* Initialize the location where the object will be inserted. */ /************************************************************************/ ptlIcon.x = 50; ptlIcon.y = 50; /************************************************************************/ /* Inserting object at location 50,50. */ /************************************************************************/ _wpCnrInsertObject(self, hwndCnr, &ptlIcon, NULL, &RecordInsert)