setnameevent.cpp

来自「IO函数调用测试」· C++ 代码 · 共 76 行

CPP
76
字号
#include "stdafx.h"
#include <afxtempl.h>

#include "IoExplorer.h"
#include "DataArray.h"
#include "TraceEvent.h"
  #include "handle.h"
    #include "HandleManager.h"
      #include "setNameEvent.h"


/****************************************************************************
*                              SetNameEvent::execute
* Result: LRESULT
*       (LRESULT)TRUE if successful
*	(LRESULT)FALSE if error
* Effect: 
*       Executes the SetName event
****************************************************************************/

LRESULT SetNameEvent::execute()
    {
     CHandle * ho = HandleList->Find(oldName);
     if(ho == NULL)
        { /* no such name */
	 result = FALSE;
	 lasterror = DISP_E_UNKNOWNNAME;
	 return (LRESULT)FALSE;
	} /* no such name */

     if(!HandleList->isUnique(newName))
        { /* duplicate name */
	 result = FALSE;
	 lasterror = ERROR_DUP_NAME;
	 return (LRESULT)FALSE;
	} /* duplicate name */
     
     ho->SetName(newName);
     
     result = TRUE;
     lasterror = 0;
     return (LRESULT)TRUE;
    }

/****************************************************************************
*                              SetNameEvent::display
* Result: CString
*       Display string for the event
* Effect: 
*       Creates a displayable string
****************************************************************************/

CString SetNameEvent::display()
    {
     CString s;
     s.Format(_T("SetName(\"%s\" => \"%s\")"), oldName, newName);
     return s;
    }

/****************************************************************************
*                        SetNameEvent::display_result
* Result: CString
*       Display result
****************************************************************************/

CString SetNameEvent::display_result()
    {
     CString s;

     if(result)
	s.LoadString(IDS_TRUE);
     else
	s.LoadString(IDS_FALSE);
     return s;
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?