按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
//{{AFX_MSG_MAP(DApp)
ON_MAND(ID_APP_ABOUT; OnAppAbout)
// NOTE the ClassWizard will add and remove mapping macros here。
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard file based document mands
ON_MAND(ID_FILE_NEW; CWinApp::OnFileNew)
ON_MAND(ID_FILE_OPEN; CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DApp construction
DApp::DApp()
{
// TODO: add construction code here;
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only DApp object
DApp theApp;
/////////////////////////////////////////////////////////////////////////////
…………………………………………………………Page 470……………………………………………………………
// DApp initialization
BOOL DApp::InitInstance()
{
// Step 1: Allocate C++ window object。
DMainFrame * pFrame;
pFrame = new DMainFrame();
// Step 2: Initialize window object。
pFrame…》LoadFrame(IDR_MAINFRAME);
// Make window visible
pFrame…》ShowWindow(m_nCmdShow);
// Assign frame as application's main window
m_pMainWnd = pFrame;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
…………………………………………………………Page 471……………………………………………………………
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg; CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App mand to run the dialog
void DApp::OnAppAbout()
{
CAboutDlg aboutDlg;
…………………………………………………………Page 472……………………………………………………………
aboutDlg。DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// DApp mands
// mainfrm。h : interface of the DMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#include // Connect to CArray template。
// Structure to track lines in text file。
class STRING
{
public:
LPTSTR pText;
int ccLen;
};
// This declaration uses the CArray template
// to provide a dynamic array of STRING records。
class StringArray : public CArray
{
public:
StringArray() {}
STRING& operator=(STRING & s)
{m_pData…》pText = s。pText;
m_pData…》ccLen = s。ccLen;
return *m_pData;}
};
…………………………………………………………Page 473……………………………………………………………
const int g_nTabCount=25;
const int g_nTabStop=4;
class DMainFrame : public CFrameWnd
{
public:
DMainFrame();
protected: // create from serialization only
DECLARE_DYNCREATE(DMainFrame)
// Attributes
public:
BOOL d_bTabs; // Respect tabs or not。
CFileDialog * d_pOpenFile; // Ptr to OpenFile dialog。
CFontDialog * d_pSetFont; // Ptr to Font Picker dialog。
CFont * d_pFont; // Ptr to CFont object。
COLORREF d_crForeground; // Foreground text color。
COLORREF d_crBackground; // Background text color。
LOGFONT d_lf; // Current logical font。
LPINT d_pnTabs; // Array of tab settings。
LPTSTR d_lpTextBuffer; // Ptr to text buffer。
DWORD d_dwFileLength; // File length。
StringArray d_saTextInfo; // Array of string info。
int d_cLines; // Count of lines in text。
int d_cyLineHeight; // Height of one line of text。
int d_clHeight; // Window height line count。
int d_iTopLine; // Index of top…most line。
int d_cyClient; // Window client area height。
…………………………………………………………Page 474……………………………………………………………
int d_cxLeftMargin; // Margin to left of text。
// Operations
public:
void BuildStringArray();
BOOL CreateNewFont();
void ResetScrollValues();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(DMainFrame)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~DMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(DMainFrame)
afx_msg void CmdFileOpen();
afx_msg void CmdFormatFont();
afx_msg void CmdFormatTabs();
afx_msg void UpdFormatTabs(CCmdUI* pCmdUI);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnPaint();
…………………………………………………………Page 475……………………………………………………………
afx_msg void OnSize(UINT nType; int cx; int cy);
afx_msg void OnVScroll(UINT nSBCode; UINT nPos; CScrollBar* pScrollBar);
afx_msg void OnWinIniChange(LPCTSTR lpszSection);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
////////////////////////////////////////////////////