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

📄 helpedit.cpp

📁 cj60lib界面库 ,ado数据库编程 使用方法: 调试代码必须装有cj60lib界面扩展库 cj60lib的使用方法参看有关文档 不知道是不是我的cj60lib出问题
💻 CPP
字号:
// HelpEditView.cpp : implementation file
//

#include "stdafx.h"
#include "vchelper.h"
#include "HelpEditView.h"
#include "mainfrm.h"
#include "vchelperdoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHelpEditView

IMPLEMENT_DYNCREATE(CHelpEditView, CView)

CHelpEditView::CHelpEditView()
{
	m_str=_T("");
	m_bhide=false;
}

CHelpEditView::~CHelpEditView()
{
}


BEGIN_MESSAGE_MAP(CHelpEditView, CView)
	//{{AFX_MSG_MAP(CHelpEditView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_LBUTTONDOWN()
	ON_COMMAND(ID_EDIT_CUT, OnEditCut)
	ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
	ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
	ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
	ON_COMMAND(ID_EDIT_CLEAR, OnEditClear)
	ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelAll)
	ON_EN_CHANGE(IDC_HELPEDIT, OnChangeData)
	ON_COMMAND(ID_UP, OnUp)
	ON_COMMAND(ID_NEXT, OnNext)
	ON_COMMAND(ID_EDIT_FILE, OnEditFile)
	ON_COMMAND(ID_DELETER_FILE, OnDeleterFile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHelpEditView drawing

void CHelpEditView::OnDraw(CDC* pDC)
{
	CVchelperDoc* pDoc = GetDocument();
	DrawCaption();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CHelpEditView diagnostics

#ifdef _DEBUG
void CHelpEditView::AssertValid() const
{
	CView::AssertValid();
}

void CHelpEditView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CHelpEditView message handlers

int CHelpEditView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_Edit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOVSCROLL,
		CRect(0,0,0,0), this, IDC_HELPEDIT))
		return -1;

    m_Font.CreatePointFont(100,"宋体");
	m_Edit.SetFont (&m_Font);
	m_Edit.SetMargins(20,20);

	
	DrawCaption();
	return 0;
}

void CHelpEditView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	m_Edit.MoveWindow(0, 30, cx, cy-30);
}

void CHelpEditView::OnListChange(CString strtopic,CString strdate)
{
	m_str=strtopic;
	DrawCaption();
	CString str="\r\n"+strdate;
	m_Edit.SetWindowText(str);
	m_bedit=false;
}

CVchelperDoc* CHelpEditView::GetDocument()
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVchelperDoc)));
	return (CVchelperDoc*)m_pDocument;
}

void CHelpEditView::FormatFont() 
{
	// TODO: Add your command handler code here
	LOGFONT lf;		//设置打开字体对话框的默认字体
	CFont *font=m_Edit.GetFont();//得到当前视图字体
	if(font==NULL)							  //当前无字体,创建默认的字体
	{
		font =new CFont;
		font->CreatePointFont(120,"Fixedsys");
		font->GetLogFont(&lf);	//初始化LOGFONT
		delete font;
	}
	else
	{
		font->GetLogFont(&lf);	//初始化LOGFONT
	}

	CFontDialog cf(&lf);
	if(cf.DoModal()==IDOK)
	{
		m_Font.DeleteObject();

		m_Font.CreateFontIndirect(&lf);
		m_Edit.SetFont(&m_Font);
	}
	
	m_Edit.SetMargins(20,20);
	DrawCaption();
}

void CHelpEditView::DrawCaption()
{
	CDC* pDC=GetDC();
	GetWindowRect(&m_rcCaption);
	ScreenToClient(&m_rcCaption);
	m_rcCaption.bottom = 30;

	
	pDC->FillSolidRect(m_rcCaption, ::GetSysColor(COLOR_BTNFACE));
	pDC->Draw3dRect(m_rcCaption, ::GetSysColor(COLOR_BTNHIGHLIGHT),
		::GetSysColor(COLOR_BTNSHADOW));

	pDC->SelectObject(&m_Font);

	pDC->SetBkMode(TRANSPARENT);
	CString str;
	str="标题:   "+m_str;
	pDC->TextOut(20,7, str);
	str="查看";
	pDC->TextOut(m_rcCaption.right-50,7, str);
}

void CHelpEditView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if (m_rcCaption.PtInRect(point))
	{
		m_bhide=!m_bhide;
		CMainFrame *pFrame = DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->m_pMainWnd);
		pFrame->HideList(m_bhide);
	}	
	CView::OnLButtonDown(nFlags, point);
}

void CHelpEditView::OnEditCut() 
{
	m_Edit.Cut();
}

void CHelpEditView::OnEditCopy() 
{
	m_Edit.Copy();
}

void CHelpEditView::OnEditPaste() 
{
	m_Edit.Paste();
}

void CHelpEditView::OnEditUndo() 
{
	m_Edit.Undo();
}

void CHelpEditView::OnEditClear() 
{
	AfxMessageBox("SD");
	m_Edit.Undo();
}

void CHelpEditView::OnEditSelAll() 
{
	m_Edit.SetSel(0,-1);
}

void CHelpEditView::OnChangeData()
{
	m_bedit=true;
}

void CHelpEditView::OnUp() 
{
	CMainFrame *pFrame = DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->m_pMainWnd);
	pFrame->GetListView()->OnUp();
}

void CHelpEditView::OnNext() 
{
	CMainFrame *pFrame = DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->m_pMainWnd);
	pFrame->GetListView()->OnNext();
}
/*
void CHelpEditView::OnSave() 
{
	if(AfxMessageBox("是否保存所做修改",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
	{
		m_pset->Edit();
		m_Edit.GetWindowText(m_pset->m_Data);
		m_pset->Update();
		m_bedit=false;
	}
}

void CHelpEditView::OnUpdateSave(CCmdUI* pCmdUI) 
{
	if(m_bedit)
		pCmdUI->Enable();
	else
		pCmdUI->Enable(false);
}
*/
void CHelpEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{	
	m_Edit.SetWindowText("");
}

void CHelpEditView::OnEditFile() 
{
	CMainFrame *pFrame = DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->m_pMainWnd);
	if( !pFrame )
	{
		return;
	}
	
	pFrame->GetListView()->OnEditFile();
}

void CHelpEditView::OnDeleterFile() 
{
	CMainFrame *pFrame = DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->m_pMainWnd);
	if( !pFrame )
	{
		return;
	}
	
	pFrame->GetListView()->OnDeleterFile();
}

⌨️ 快捷键说明

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