コード例 #1
0
// 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;
    }
}
コード例 #2
0
int Container::insert(char *name,UserData *parent,ULONG arg1,ULONG arg2)
{
    UserData *ud;
    
    ud = allocateRecords(1);
    if (ud)
    {
        last_insert = ud;
        
//        objects[num_objects] = ud;  // keep a pointer to the block
        num_objects++;
        
        // set all the stuff in our record
        ud->setName(name);
        if (arg1 == arg2 && arg1 == 7777L)
        {
            ud->setType(TYPE_GROUP);
            ud->setIcons(icon_group_o,icon_group_c);
        }
        else if (arg1 == arg2 && arg1 == 8888L)
        {
            ud->setType(TYPE_FILE);
            ud->setParent(parent);
            HPOINTER the_icon;
            if (*name)
            {
                the_icon = determineIcon(name);
//
//                if (the_icon != icon_dunno)
//                {
                    ud->setIcons(the_icon,the_icon);
//                }
//                else
//                {
//                    // TRY TO LOAD THE Shared WPS ICON
//                    the_icon = WinLoadFileIcon(name,FALSE);
//                    if (the_icon != NULL)
//                    {
//                        ud->setIcons(the_icon,the_icon);
//                        WinSendMsg(cont,CM_INVALIDATERECORD,MPFROMP(&ud),MPFROM2SHORT(1,CMA_TEXTCHANGED|CMA_REPOSITION));
//                    }
//                }
            }
            
        }
        else if (parent == NULL)
        {
            ud->setType(TYPE_SERVER);
            ud->setIcons(icon_server,icon_server);
        }
        else
        {
            ud->setType(TYPE_GROUP);
            ud->setParent(parent);
            ud->setIcons(icon_group_o,icon_group_c);
        }
        
        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 = WinSendDlgItemMsg(dialog,id,CM_INSERTRECORD,MPFROMP((PRECORDCORE)ud),MPFROMP(&ri));
        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;
    }
}