学习设计了一个类似OUTLOOK的邮箱界面,用cxgrid怎么去实现对收到的信件的拖放移动功能(把邮件从一个文件里直接拖到另一个文件夹下)。

解决方案 »

  1.   

    记得在cxgrid的DEMO中是有这个功能的
      

  2.   

    cxgrid安裝後的控件包中有一個demo可以實現這樣的功能,你直接引用裡面的單元即可...
      

  3.   


    function TboEMCAccount.MoveMessage(const sUID: WideString; vMsgID,
      vFolderID, vProfileID: OleVariant; bCheckAccess: WordBool): WordBool;
    var
      iCount:integer;
      rsMsg: _Recordset;
      vSemaID: OleVariant;
    begin
      try
        if bCheckAccess then
        begin
          if not (VarIsNull(vFolderID) or VarIsEmpty(vFolderID) or (VarToStr(vFolderID) = '')) then
          begin
            if vFolderID > 0 then
            begin
              if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
                m_oboFolder.GetThisUser(sUID, vFolderID) then
              begin
                if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                  RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
              end;
            end;
          end
          else
            RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCFolderIDEmpty);          if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);      if not (VarIsNull(vProfileID) or VarIsEmpty(vProfileID) or (VarToStr(vProfileID) = '')) then
          begin
            if UpperCase(m_oboUserInfo.GetLoggedInUser(sUID)) <>
              m_odoEMCAccount.GetThisUser(sUID, vProfileID) then
            begin
              if not m_oboUserInfo.GetAccessPass(sUID, 0, 'EMC_MOVEMESSGES') then
                RaiseValidationError(OTBusinessObject,sUID,'TboEMCAccount.MoveMessage', AccessDenied);
            end;
          end
          else
            RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCProfileIDIsNull);
        end;      if VarIsArray(vMsgID) then
          begin
            for iCount := 0 to VarArrayHighBound(vMsgID,1)-1 do
            begin
               rsMsg :=  m_odoEMCMessage.Fetch(sUID, varToStr(vmsgid[iCount]), False);
            if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
            begin
              rsMsg.Fields['FLDID'].Value := vFolderID;
              rsMsg.Fields['PRFID'].Value := vProfileID;          rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True);      // if html formated mails then we will need to set the cids according to the
          // new attachments so that the images can be rendered properly...
          if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
            (rsMsg.Fields['HASATTACH'].Value = 'T') then
          begin
            UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
              rsMsg.Fields['BODY'].Value, bCheckAccess);
          end;
          Result := True;
        end
        else
          RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);
               end;
          end
        else
        begin
             rsMsg :=  m_odoEMCMessage.Fetch(sUID, vMsgID, False);
            if Assigned(rsMsg) and (rsMsg.RecordCount = 1) then
            begin
              rsMsg.Fields['FLDID'].Value := vFolderID;
              rsMsg.Fields['PRFID'].Value := vProfileID;          rsMsg := m_odoEMCMessage.Update(sUID, rsMsg, True);          // if html formated mails then we will need to set the cids according to the
              // new attachments so that the images can be rendered properly...
              if (rsMsg.Fields['MESSAGE_FORMAT'].Value = 2) and
                (rsMsg.Fields['HASATTACH'].Value = 'T') then
              begin
                UpdateHtmlMessage(sUID, rsMsg.Fields['MSGID'].Value,
                  rsMsg.Fields['BODY'].Value);
              end;          Result := True;
            end
            else
              RaiseValidationError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCInvalidMessageError);    end;  except
        on E:Exception do
        begin
          SetAbort;
          if (not VarIsEmpty(vSemaID)) and m_oboSemaphore.LockExists(sUID, vSemaID) then
            m_oboSemaphore.UnLockRecord(sUID, vSemaID);
          HandleEverestError(OTBusinessObject, sUID, 'TboEMCAccount.MoveMessage', EMCMoveMessageError, E);
          Result := False;
        end;
      end;
    end;
    关于邮件移动到别的文件夹的一个函数