// Insert a Server Object int Container::insert(char *name,char *user,char *pass,ULONG arg1,ULONG arg2) { UserData *ud; UserData *parent = NULL; ud = allocateRecords(1); if (ud) { last_insert = ud; num_objects++; // set all the stuff in our record ud->setName(name); ud->setUsername(user); ud->setPassword(pass); ud->setType(TYPE_SERVER); ud->setIcons(icon_server,icon_server); ud->setCull(arg1); ud->setStart(arg2); // Build up insertion information RECORDINSERT ri; memset(&ri,0,sizeof(RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); ri.zOrder = CMA_END; // add on top of siblings if (!parent || !parent->getCollapsed()) ri.fInvalidateRecord = TRUE; // re-arrange after insert ri.pRecordParent = (PRECORDCORE)parent; // set tree hierarchy ri.cRecordsInsert = 1; // number of records to insert ri.pRecordOrder = (RECORDCORE*)CMA_END; // add to end of list MRESULT rc = WinSendMsg(cont,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri)); if (rc == 0) message("CM_INSERTRECORD returned %d",rc); return 1; } else { DosBeep(100,100); return 0; } }
UserData *Container::reInsert(UserData *ud,HPOINTER icon) { PRECORDCORE parent; parent = (PRECORDCORE)WinSendMsg(cont,CM_QUERYRECORD,MPFROMP(ud),MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER)); if (parent == NULL) parent = (PRECORDCORE)CMA_FIRST; // make a backup of our object UserData keep; memcpy(&keep,ud,sizeof(UserData)); // remove AND delete (takes out any kids too!) WinSendMsg(cont,CM_REMOVERECORD,MPFROMP(&ud),MPFROM2SHORT(1,CMA_FREE)); ud = allocateRecords(1); ud->setName(keep.getName()); ud->setSkipped(keep.getSkipped()); ud->setCollapsed(keep.getCollapsed()); ud->setCull(keep.getCull()); ud->setStart(keep.getStart()); ud->setType(keep.getType()); ud->setParent(keep.getParent()); ud->setIcons(icon,icon); RECORDINSERT ri; memset(&ri,0,sizeof(RECORDINSERT)); ri.cb = sizeof(RECORDINSERT); if (!keep.getParent() || !keep.getParent()->getCollapsed()) ri.fInvalidateRecord = TRUE; ri.pRecordParent = (PRECORDCORE)ud->getParent(); ri.pRecordOrder = (RECORDCORE*)parent; ri.cRecordsInsert = 1; // number of records to insert // re-insert WinSendMsg(cont,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri)); setItemFocus(ud); return ud; }