记事本程序设置字体颜色
来源:百度知道 编辑:UC知道 时间:2024/05/22 05:05:49
void CYQNotepadView::OnFormatFont()
{
// TODO: Add your command handler code here
LOGFONT lf; //设置打开字体对话框的默认字体
CFont *font=this->GetEditCtrl().GetFont(); //得到当前视图字体
if(font==NULL) //当前无字体,创建默认的字体
{
font =new CFont;
font->CreatePointFont(120,"Fixedsys");
font->GetLogFont(&lf); //初始化LOGFONT
delete font;
}
else
{
font->GetLogFont(&lf); //初始化LOGFONT
}
CFontDialog dlg(&lf);
if(dlg.DoModal()==IDOK)
{
this->m_Font.DeleteObject();
this->m_Font.CreateFontIndirect(&lf); //创建字体
this->SetFont(&this->m_Font);
}
}
请问怎么在代码中实现设置字体颜色的功能?如需源码,请留言,能达到要求者必追加。
复制粘贴一下
// cseView.h : interface of the CCseView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CSEVIEW_H__5EC581F1_BEE5_4D81_BDC8_82911EE6826E__INCLUDED_)
#define AFX_CSEVIEW_H__5EC581F1_BEE5_4D81_BDC8_82911EE6826E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "cseDoc.h"
class CCseView : public CEditView
{
protected: // create from serialization only
CCseView();
DECLARE_DYNCREATE(CCseView)
CFont m_Font;
// Attributes
public:
CCseDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCseView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual CScrollBar* GetSc