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

📄 mainfrm.cpp

📁 微型文本编辑器. 多文档界面
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "Wediter.h"
#include "MainFrm.h"

//#include "picturevariable.h"

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


/////////////////////////////////////////////////////////////////////////////
// CMainFrame


IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_WM_TIMER()
	ON_WM_SIZE()
	ON_WM_SETFOCUS()
	ON_WM_CLOSE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
	// Global help commands
	ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
	ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
	ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
	ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)

END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_SEPARATOR,
	ID_SEPARATOR,
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
	ID_INDICATOR_CLOCK,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	
	CRect rect;
	m_wndToolBar.GetItemRect(0,&rect);
	m_wndToolBar.SetSizes(rect.Size(),CSize(16,15));
	m_wndToolBar.SetButtonInfo(17,ID_FIND_TEXT,TBBS_SEPARATOR,200);
	m_wndToolBar.GetItemRect(17,&rect);
	rect.bottom+=80;
	//CBS_DROPDOWNLIST 不可编辑
	//CBS_DROPDOWN 可编辑
	if(!m_findComboBox.Create(CBS_DROPDOWN|WS_VISIBLE|WS_TABSTOP|
		CBS_AUTOHSCROLL|WS_VSCROLL,rect,&m_wndToolBar,IDR_FIND_COMBOBOX))
	{
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}
	//设置x-y坐标信息窗口宽度
	m_wndStatusBar.SetPaneInfo(1,0,0,50);
    m_wndStatusBar.SetPaneInfo(2,0,0,50);

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable

	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	if(gapp.tool==1)
		m_wndToolBar.ShowWindow(SW_SHOW);
	else
		m_wndToolBar.ShowWindow(SW_HIDE);

	if(gapp.stats==1)
		m_wndStatusBar.ShowWindow(SW_SHOW);
	else
		m_wndStatusBar.ShowWindow(SW_HIDE);

	//初始化图象控件
	m_imgidx=0;
	m_imglst.Create(16,16,ILC_MASK|ILC_COLOR8,16,3);
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON2));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON4));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON5));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON6));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON7));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON8));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON9));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON10));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON11));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON12));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON13));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON14));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON15));
	m_imglst.Add(AfxGetApp()->LoadIcon(IDI_ICON16));


    SetTimer(1,1000,NULL);

	return 0;
}


/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

void CMainFrame::OnTimer(UINT nIDEvnt)
{
	if(gapp.time==1)
	{
		CTime t=CTime::GetCurrentTime();
		CString time=t.Format("%H:%M:%S");
		m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_CLOCK),time);
	}
	if(gapp.icon==1)
	{
		AfxGetMainWnd()->SetIcon(m_imglst.ExtractIcon(m_imgidx),TRUE);
		if (m_imgidx<m_imglst.GetImageCount())
			m_imgidx=m_imgidx+1;
		else
			m_imgidx=0;
	}
	

	CFrameWnd::OnTimer(nIDEvnt);
}


void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	CMDIFrameWnd::OnSize(nType, cx, cy);
	if (nType==SIZE_MINIMIZED)
		AfxGetMainWnd()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME_MIN),TRUE);
	else
		AfxGetMainWnd()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME),TRUE);

	// TODO: Add your message handler code here

}

void CMainFrame::OnSetFocus(CWnd* pOldWnd) 
{
	CMDIFrameWnd::OnSetFocus(pOldWnd);

	// TODO: Add your message handler code here
	m_wndStatusBar.SetPaneText(1,"Row:");
	m_wndStatusBar.SetPaneText(2,"Col:");
}



void CMainFrame::OnClose() 
{
 	KillTimer(1);

	// TODO: Add your message handler code here and/or call default
	CMDIFrameWnd::OnClose();
}

void CMainFrame::OnDestroy() 
{
	CMDIFrameWnd::OnDestroy();
	
	// TODO: Add your message handler code here
	pview=NULL;
	delete pview;
}


⌨️ 快捷键说明

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