//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// mainfrm。cpp : implementation of the DMainFrame class
//
#include 〃stdafx。h〃
#include 〃filelist。h〃
#include 〃mainfrm。h〃
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE'' = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DMainFrame
IMPLEMENT_DYNCREATE(DMainFrame; CFrameWnd)
BEGIN_MESSAGE_MAP(DMainFrame; CFrameWnd)
//{{AFX_MSG_MAP(DMainFrame)
ON_MAND(ID_FILE_OPEN; CmdFileOpen)
ON_MAND(ID_FORMAT_FONT; CmdFormatFont)
ON_MAND(ID_FORMAT_TABS; CmdFormatTabs)
ON_UPDATE_MAND_UI(ID_FORMAT_TABS; UpdFormatTabs)
ON_WM_CREATE()
…………………………………………………………Page 476……………………………………………………………
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_VSCROLL()
ON_WM_WININICHANGE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DMainFrame construction/destruction
DMainFrame::DMainFrame()
{
// Init all data members to a known value。
d_pOpenFile = 0;
d_lpTextBuffer = 0;
d_dwFileLength = 0;
d_pFont = 0;
// Init desired font。
memset (&d_lf; 0; sizeof(LOGFONT));
// Initial font face name is Courier New。
lstrcpy (d_lf。lfFaceName; _T(〃Courier New〃));
// Initial font size is 10 pt。
CWindowDC dc(NULL);
int cyPixels = dc。GetDeviceCaps(LOGPIXELSY);
d_lf。lfHeight = (…1) * MulDiv(10; cyPixels; 72);
// Initial tab setting is OFF。
d_bTabs = TRUE;
// Tab table initially empty (set when font selected)。
…………………………………………………………Page 477……………………………………………………………
d_pnTabs = 0;
}
DMainFrame::~DMainFrame()
{
if (d_pFont) delete d_pFont;
if (d_pnTabs) delete '' d_pnTabs;
if (d_pOpenFile) delete d_pOpenFile;
if (d_pSetFont) delete d_pSetFont;
}
///////////////////////////////////////////////////////////////////////////////
// DMainFrame helper functions。
//…………………………………………………………………………………………………………………………………………………………………………………………………………
// BuildStringArray …Parses text file to create a CString array。
void DMainFrame::BuildStringArray()
{
// Scan buffer to calculate line count。
LPTSTR lpNext = d_lpTextBuffer;
LPTSTR lpEnd = d_lpTextBuffer + d_dwFileLength 1;
*lpEnd = "n";
for (d_cLines = 0; lpNext 《 lpEnd; d_cLines++; lpNext++)
{
// Search for next character。
lpNext = strchr(lpNext; "n");
// Discontinue if NULL encountered。
if (lpNext == NULL) break;
}
…………………………………………………………Page 478……………………………………………………………
// Set array size。
d_saTextInfo。SetSize(d_cLines);
// Scan buffer to build array of pointers & sizes。
STRING string;
lpNext = d_lpTextBuffer;
for (int iLine = 0; iLine 《 d_cLines; iLine++)
{
// Char count for current line。
string。ccLen = 0;
string。pText = lpNext;
// Loop to end…of…line。
while ((*lpNext != "n") && (*lpNext != "r"))
{
lpNext++; // Check next char。
string。ccLen++; // Increment length counter。
}
// Enter value in array。
d_saTextInfo'iLine' = string;
// Skip over
lpNext += (2 * sizeof(char));
}
}
//…………………………………………………………………………………………………………………………………………………………………………………………………………
// CreateNewFont …Creates new CFont for use in drawing text。
BOOL DMainFrame::CreateNewFont()
{
…………………………………………………………Page 479……………………………………………………………
// Delete any previous font。
if (d_pFont)
delete d_pFont;
// Create a new font
d_pFont = new CFont();
if (!d_pFont) return FALSE;
d_pFont…》CreateFontIndirect(&d_lf);
// Calculate font height
CClientDC dc(this);
TEXTMETRIC tm;
dc。SelectObject(d_pFont);
dc。GetTextMetrics(&tm);
d_cyLineHeight = tm。tmHeight + tm。tmExternalLeading;
// Calculate left margin。
d_cxLeftMargin = tm。tmAveCharWidth * 2;
// Rebuild tab setting table。
if (d_pnTabs) delete '' d_pnTabs;
d_pnTabs = new INT'g_nTabCount';
for (int i=0; i
小说推荐
- C语言游戏编程从入门到精通(PDF格式)
- -Page 1-Page 2-Page 3-Page 4-Page 5-Page 6-Page 7-Page 8-Page 9-Page 10-Page 11-Page 12-Page 13-Page 14
- 最新章:第4章
- JMS简明教程(PDF格式)
- -Page 1-JMS1.1规范中文版卫建军2007‐11‐22-Page 2
- 最新章:第28章
- SQL语言艺术(PDF格式)
- -Page 1-SQLSSQQLL语言艺术内容介绍本书分为12章,每一章包含许多原则或准则,并通过举例的方式对原则进行解释说明。这些例子大多来自于实际案例,对九种SQL经典查询场景以及其性能影响讨论,非常便于实践,为你数据库应用维护人员阅读。资深 SQL 专家 Stéphane Faroult倾力打
- 最新章:第27章
- 软件工程实践者的思想(PDF格式)
- -Page 1-大 道 至 简—软件工程实践者的思想周爱民(Aimingoo 著-Page 2-序2004 年 11 月初爱民(Aimingoo)第一次把他的书稿给我,我翻看了一下,第一反应讲的是感想。这不错,在技
- 最新章:第26章
- asp基础实用教程(DOC格式)
- 目 录一、关于ASP二、ASP的新功能三、创建ASP页四、使用脚本语言五、使用变量和常量六、使用集合七、ASP内建对象八、向浏览器发送内容九、包含文件十、访问数据库十一、调试ASP脚本十二、维护ASP应用程序的安全一、关于ASP Active Server Pages(ASP)是服务器端脚本编写环境
- 最新章:第17章
- Linux实用培训教程(PDF)
- -Page 1-rrktqt的个人空间 Linux实用培训教程第一部分 作者:红联Linux实用培训教程第一部分-共三部分解的Linux知识,循序渐进的介绍Linux相关知识,从入门到提高,希望对所有学习Linux的朋友都有帮助 红联Linux论坛是致力于Linux技术讨论的站点,目前网站收录的文章
- 最新章:第42章
- php程序设计简明教程(DOC格式)
- -Page 1-PHP 程序设计简明教程PHP 讲义 第 1 页 共 90 页-Page 2-目录序 4第一章 PHP 简介 6
- 最新章:第31章
- 路由器基本知识及应用实例(DOC格式)
- 第二章 路由器第一节 路由器发展概述自从1984年问世至今,路由器已经走过了近20年的快速技术发展历程。路由器的应用领域不断扩展、从单一的互通网关逐渐扩展到覆盖广域网、城域网乃至用户接入的各个领域。近年来,路由器早已逐渐脱离单纯用于企业网出口和互联的概念,开始成为运营网络和各种专用业务网络的核心设备
- 最新章:第48章
- Java编程思想第4版[中文版](PDF格式)
- -Page 1-Page 2《Thinking In Java》中文版作者:Bruce Eckel主页:http/BruceEckel.编译:Trans Bot主页:http/memberease~transbot致谢-献给那些直到现在仍在孜孜不倦创造下一代计算机语言的人们!指导您利用万维网的语言进
- 最新章:第295章