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

📄 generpg.cpp

📁 一个完整的编辑器的代码(很值得参考
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////
//  File:    generpg.cpp
//  Version: 1.1.0.4
//  Updated: 19-Jul-1998
//
//  Property page with general information
//
//  Copyright:  Ferdinand Prantl
//  E-mail:     prantl@ff.cuni.cz
//
//  You are free to use or modify this code to the following restrictions:
//  - Acknowledge me somewhere in your about box, simple "Parts of code by.."
//  will be enough. If you can't (or don't want to), contact me personally.
//  - LEAVE THIS HEADER INTACT
////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "generpg.h"
#include "editpaddoc.h"
#include "editpadview.h"
#include "foldrdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGeneralPage property page

IMPLEMENT_DYNCREATE(CGeneralPage, CPropertyPage)

CGeneralPage::CGeneralPage() : CPropertyPage(CGeneralPage::IDD), m_pParent (&theApp)
{
  //{{AFX_DATA_INIT(CGeneralPage)
  m_bOpenLastDoc = FALSE;
  m_bMaxWnd = FALSE;
  m_bSaveDocOnExit = FALSE;
  m_bSaveSetingsOnExit = FALSE;
  m_bAutoReload = FALSE;
  m_bNotifyChanges = TRUE;
  m_bAdvancedUi = TRUE;
  m_bNoSplash = FALSE;
  m_sIspellPath = _T("");
	m_bRememberLastPos = TRUE;
  //}}AFX_DATA_INIT
}

CGeneralPage::~CGeneralPage()
{
}

void CGeneralPage::DoDataExchange(CDataExchange* pDX)
{
  CPropertyPage::DoDataExchange(pDX);
  //{{AFX_DATA_MAP(CGeneralPage)
  DDX_Check(pDX, IDC_OPEN_LAST_DOC, m_bOpenLastDoc);
  DDX_Check(pDX, IDC_MAXIMIZE_WND, m_bMaxWnd);
  DDX_Check(pDX, IDC_SAVE_DOC_ON_EXIT, m_bSaveDocOnExit);
  DDX_Check(pDX, IDC_SAVE_SETS_ON_EXIT, m_bSaveSetingsOnExit);
  DDX_Check(pDX, IDC_DRAG_N_DROP_EDIT, m_bDragnDropEditing);
  DDX_Check(pDX, IDC_AUTORELOAD, m_bAutoReload);
  DDX_Check(pDX, IDC_NOTIFY_CHANGES, m_bNotifyChanges);
  DDX_Check(pDX, IDC_ADVANCED_UI, m_bAdvancedUi);
  DDX_Check(pDX, IDC_NO_SPLASH, m_bNoSplash);
  DDX_Text(pDX, IDC_ISPELL_PATH, m_sIspellPath);
  DDX_Check(pDX, IDC_REMEMBER_LASTPOS, m_bRememberLastPos);
  //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CGeneralPage, CPropertyPage)
//{{AFX_MSG_MAP(CGeneralPage)
ON_BN_CLICKED(IDC_OPEN_LAST_DOC, OnModify)
ON_BN_CLICKED(IDC_ISPELL_PATH_BUT, OnIspellPathBut)
ON_BN_CLICKED(IDC_MAXIMIZE_WND, OnModify)
ON_BN_CLICKED(IDC_SAVE_DOC_ON_EXIT, OnModify)
ON_BN_CLICKED(IDC_SAVE_SETS_ON_EXIT, OnModify)
ON_BN_CLICKED(IDC_DRAG_N_DROP_EDIT, OnModify)
ON_BN_CLICKED(IDC_NOTIFY_CHANGES, OnModify)
ON_BN_CLICKED(IDC_ADVANCED_UI, OnModify)
ON_BN_CLICKED(IDC_NO_SPLASH, OnModify)
ON_EN_CHANGE(IDC_ISPELL_PATH, OnModify)
ON_BN_CLICKED(IDC_REMEMBER_LASTPOS, OnModify)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGeneralPage message handlers


BOOL CGeneralPage::OnInitDialog() 
{
  ASSERT (m_pParent);
  m_bOpenLastDoc = (m_pParent->m_dwFlags & EP_OPEN_LAST_DOC) != 0;
  m_bMaxWnd = (m_pParent->m_dwFlags & EP_MAXIMIZE_WND) != 0;
  m_bSaveDocOnExit = (m_pParent->m_dwFlags & EP_SAVE_DOC_ON_EXIT) != 0;
  m_bSaveSetingsOnExit = (m_pParent->m_dwFlags & EP_SAVE_SETS_ON_EXIT) != 0;
  m_bDragnDropEditing = (m_pParent->m_dwFlags & EP_DRAG_N_DROP_EDIT) != 0;
  m_bAutoReload = (m_pParent->m_dwFlags & EP_AUTO_RELOAD) != 0;
  m_bNotifyChanges = (m_pParent->m_dwFlags & EP_NOTIFY_CHANGES) != 0;
  m_bAdvancedUi = (m_pParent->m_dwFlags & EP_ADVANCED_UI) != 0;
  m_bNoSplash = (m_pParent->m_dwFlags & EP_NO_SPLASH) != 0;
  m_sIspellPath = CEditPadView::szWIspellPath;
  m_bRememberLastPos = (m_pParent->m_dwFlags & EP_REMEMBER_LASTPOS) != 0;

  CPropertyPage::OnInitDialog();

  return TRUE;  // return TRUE unless you set the focus to a control
                // EXCEPTION: OCX Property Pages should return FALSE
}

void CGeneralPage::OnOK() 
{
  CPropertyPage::OnOK();

  ASSERT (m_pParent);
  if ((m_bNotifyChanges != 0) !=  ((m_pParent->m_dwFlags & EP_NOTIFY_CHANGES) != 0))
    {
      POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition ();
      ASSERT (pos);
      CDocTemplate *pDocTempl = AfxGetApp ()->GetNextDocTemplate (pos);
      pos = pDocTempl->GetFirstDocPosition ();
      if (m_bNotifyChanges)
        while (pos)
          {
            CEditPadDoc *pDoc = (CEditPadDoc*) pDocTempl->GetNextDoc (pos);
            pDoc->AddFile (pDoc->GetPathName ());
            pDoc->StartWatching ();
          }
      else
        while (pos)
          {
            CEditPadDoc *pDoc = (CEditPadDoc*) pDocTempl->GetNextDoc (pos);
            pDoc->StopWatching ();
            pDoc->RemoveFile (pDoc->GetPathName ());
          }
    }
  if ((m_bAdvancedUi != 0) !=  ((m_pParent->m_dwFlags & EP_ADVANCED_UI) != 0))
    {
      AfxMessageBox (_T ("Changes of the advanced user interface\ndo not take effect until EditPad is restarted."));
    }
  m_pParent->m_dwFlags = (m_bOpenLastDoc ? EP_OPEN_LAST_DOC : 0) |
    (m_bMaxWnd ? EP_MAXIMIZE_WND : 0) |
    (m_bSaveDocOnExit ? EP_SAVE_DOC_ON_EXIT : 0) |
    (m_bSaveSetingsOnExit ? EP_SAVE_SETS_ON_EXIT : 0) |
    (m_bDragnDropEditing ? EP_DRAG_N_DROP_EDIT : 0) |
    (m_bAutoReload ? EP_AUTO_RELOAD : 0) |
    (m_bNotifyChanges ? EP_NOTIFY_CHANGES : 0) |
    (m_bAdvancedUi ? EP_ADVANCED_UI : 0) |
    (m_bNoSplash ? EP_NO_SPLASH : 0) |
    (m_bRememberLastPos ? EP_REMEMBER_LASTPOS : 0);
  POSITION pos = m_pParent->GetFirstDocTemplatePosition ();
  ASSERT (pos);
  CDocTemplate *pDocTempl = m_pParent->GetNextDocTemplate (pos);
  ASSERT (pDocTempl);
  pos = pDocTempl->GetFirstDocPosition ();
  ASSERT (pos);
  CDocument *pDoc = pDocTempl->GetNextDoc (pos);
  ASSERT (pDoc);
  pos = pDoc->GetFirstViewPosition ();
  CEditPadView *pView;
  while (pos)
    {
      pView = (CEditPadView*) pDoc->GetNextView (pos);
      pView->SetDisableDragAndDrop (m_bDragnDropEditing);
    }
  _tcscpy (CEditPadView::szWIspellPath,  m_sIspellPath);
  SetModified (FALSE);
}

void CGeneralPage::OnModify() 
{
  SetModified ();
}

void CGeneralPage::OnIspellPathBut() 
{
  UpdateData ();
  TCHAR szPath[_MAX_PATH];
  if (folderdlg (szPath, m_sIspellPath, NULL, 0, GetSafeHwnd ()) == IDOK)
    {
      m_sIspellPath = szPath;
      UpdateData (FALSE);
      SetModified ();
    }
}

⌨️ 快捷键说明

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