⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msdswprj.cpp

📁 一个完整的编辑器的代码(很值得参考
💻 CPP
字号:

#include "stdafx.h"
#include "editcmd.h"
#include "resource.h"
#include "msdswprj.h"
#include "msdspprj.h"
#include "filesup.h"
	
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#pragma warning ( disable : 4711 )
/////////////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC (CMsDswProject, CProject)

CMsDswProject::CMsDswProject ()
  {
  }

bool freadln (FILE *fp, LPTSTR pszLine, size_t nSize);

#define PROJECT _T ("Project:")
#define PROJECT_LEN 8

bool CMsDswProject::OpenDsw (CProject *pProject, LPCTSTR pszPath)
  {
    CWaitCursor wait;

    if (!FileExist (pszPath))
      return false;

    FILE *fp = _tfopen (pszPath, _T ("rt"));
    if (!fp)
      return false;

    TCHAR szLine[256];
    int nLine;
    bool bEoln;

    CProjectItem *pNew;
    CString sExPath = GetPath (pszPath, TRUE);

    do
      {
        _fgetts (szLine, sizeof (szLine), fp);
        nLine = _tcslen (szLine);
        bEoln = szLine[nLine - 1] == _T ('\n');
        if (bEoln)
          szLine[nLine-- - 1] = _T ('\0');
        if (!_tcsnicmp (szLine, PROJECT, PROJECT_LEN))
          {
            LPTSTR pszFirst = _tcschr (szLine, _T ('\\')), pszLast = _tcsrchr (szLine, _T ('-'));
            if (pszFirst && pszLast)
              {
                pNew = new CProjectItem;
                if (pszLast[-2] == _T ('\"'))
                  pszLast[-2] = _T ('\0');
                else
                  pszLast[-1] = _T ('\0');
                pNew->sPath = pszFirst + 1;
                pNew->sMidPath = _T ("");
                pNew->dwType = PI_GROUP|PI_ROOT|PI_SUBITEM;
                pProject->lstItems.AddTail (pNew);
                CMsDspProject::OpenDsp (pProject, pNew, sExPath + pNew->sPath, GetPath (pNew->sPath, TRUE));
              }
          }
        if (!bEoln && !freadln (fp, szLine, sizeof (szLine)) || feof (fp))
          break;
      }
    while (!feof (fp));

    fclose (fp);
    pProject->sPath = pszPath;
    return true;
  }

bool CMsDswProject::Open (LPCTSTR pszPath)
  {
    return OpenDsw (this, pszPath);
  }

bool CMsDswProject::Save (LPCTSTR pszPath)
  {
    AfxMessageBox (_T ("Not implemented yet."));
    return false;
  }

/////////////////////////////////////////////////////////////////////////////
#pragma warning ( default : 4711 )

⌨️ 快捷键说明

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