亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? formatbar.shtml

?? mfc資源大全包含MFC編程各個方面的源碼
?? SHTML
?? 第 1 頁 / 共 2 頁
字號:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Zafir Anjum">
   <TITLE>Rich Edit Control - Providing a Format toolbar</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000" bgproperties="fixed">
<table WIDTH="100%">
<tr WIDTH="100%">
<td align=center><!--#exec cgi="/cgi/ads.cgi"--><td>
</tr>
</table>


<CENTER>
<H3>
<FONT COLOR="#AOAO99">Providing a Format toolbar</FONT></H3></CENTER>

<HR>

A rich edit control without UI to change the character and paragraph formatting is not really very useful as a rich text editor. In this section we will develop code for a Format toolbar that can be used with a CRichEditView derivative. There is no hard link between the toolbar itself and the CRichEditView, so we can even use this toolbar with a sub-class of CRichEditCtrl. The only extra work would be to make sure that some of the notifications sent by the toolbar gets forwarded to the control.

<P>There is a huge scope for improvement in the code given here, but intergrating this in your application should be fairly easy. When you feel that you need more functionality out of the Format toolbar, take a look at the WordPad sample that comes with your Visual C++ CD. This sample is the actual source code for the WordPad applet that ships with Windows. Be warned though, it takes a little time to understand the code. 

<H4>Step 1: Create a toolbar control resource</H4>
The first thing we need to do is create a toolbar control resource. Actually you can create a toolbar from a bitmap but it is lot easier to work with a toolbar control. The resource editor has quite a good support for it.

<P>This is what the toolbar control looks like in the resource editor. Give the toolbar control resource the ID - IDR_FORMATBAR. Actually choose any name but you should be willing to replace all occurance of IDR_FORMATBAR in the code below with the new ID.


<P>The first two buttons are place holders for the Font Name combobox and the Font Size combobox. The other buttons are pretty obvious. Once we have the images, we should go ahead and set the properties. Besides specifying an ID for each button, we should also provide the prompt string. The prompt string is used for the help text that appears in the status bar and the tooltip text.



<P>The 'Toolbar Button Properties' dialog is shown above for the Font Name button. The table below lists suggested IDs and prompt strings - in the same sequence they appear in the toolbar.

<p>
<TABLE BORDER=1 WIDTH="100%" >
<TR><TD WIDTH="30%" BGCOLOR="#A0A0A0">ID</A></TD><TD WIDTH="70%" BGCOLOR="#A0A0A0">Prompt</TD></TR>
<TR><TD>IDC_FONTNAME</A></TD><TD>Changes the font of the selection\nFont</TD></TR>
<TR><TD>IDC_FONTSIZE</A></TD><TD>Changes the font size of the selection\nFont Size</TD></TR>
<TR><TD>ID_CHAR_BOLD</A></TD><TD>Makes the selection bold (toggle)\nBold</TD></TR>
<TR><TD>ID_CHAR_ITALIC</A></TD><TD>Makes the selection italics (toggle)\nItalic</TD></TR>
<TR><TD>ID_CHAR_UNDERLINE</A></TD><TD>Formats the selection with a continuous underline (toggle)\nUnderline</TD></TR>
<TR><TD>ID_CHAR_COLOR</A></TD><TD>Formats the selection with a color\nColor</TD></TR>
<TR><TD>ID_PARA_LEFT</A></TD><TD>Left-justifies paragraphs\nLeft Justify</TD></TR>
<TR><TD>ID_PARA_CENTER</A></TD><TD>Center-justifies paragraphs\nCenter Justify</TD></TR>
<TR><TD>ID_PARA_RIGHT</A></TD><TD>Right-justifies paragraph\nRight Justify</TD></TR>
<TR><TD>ID_INSERT_BULLET</A></TD><TD>Inserts a bullet on this line\nBullet</TD></TR>
</TABLE>


<H4>Step 2: Create a CFormatBar class</H4>
I used the Class Wizard to create this class. The class wizard did not have the option of specifying the CToolBar class as the base class, so I chose the CToolBarCtrl class as the base class and then in the source files, changed it to CToolBar. The advantage of using a CToolBar is that it is already hooked into the Doc-View architecture of MFC. This helps in updating the toolbar and the status bar.

<P>The code for the CFormatBar class header file is given below. You will notice that besides declaring the CFormatBar class, it also declares CHARNMHDR struct. This is used to send custom notification messages whenever the font name or the font size changes. The FN_SETFORMAT and FN_GETFORMAT defines are the custom notification message values. 

<P>The CFormatBar constructor takes a default value which is set to IDR_FORMATBAR. This is useful only if you already have a resource with the ID IDR_FORMATBAR that you are using for some other purpose.

<PRE><TT><FONT COLOR="#990000">#if !defined(AFX_FORMATBAR_H__76705223_1E1F_11D1_830C_5CB0BB000000__INCLUDED_)
#define AFX_FORMATBAR_H__76705223_1E1F_11D1_830C_5CB0BB000000__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// FormatBar.h : header file
//



/////////////////////////////////////////////////////////////////////////////
// CFormatBar window

struct CHARNMHDR : public NMHDR
{
	CHARFORMAT cf;
	CHARNMHDR() {cf.cbSize = sizeof(CHARFORMAT);}
};

// Define format notifications constant
#define FN_SETFORMAT	0x1000
#define FN_GETFORMAT	0x1001


class CFormatBar : public CToolBar
{
// Construction
public:
	enum { IDD = IDR_FORMATBAR };
	CFormatBar(UINT nID = IDD );

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CFormatBar)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CFormatBar();

protected:
	void FillFontName( CDC *pDC );
	virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);


protected:
	CComboBox	m_cmbFontName;
	CComboBox	m_cmbFontSize;

	// Generated message map functions
protected:
	afx_msg void OnSelectFontName();
	afx_msg void OnSelectFontSize();

	//{{AFX_MSG(CFormatBar)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()

private:
	UINT nToolbarID;
	static int CALLBACK EnumFontFamProc(ENUMLOGFONT *lpelf, 
					NEWTEXTMETRIC *lpntm,
					int nFontType,
					LPARAM lParam);

};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FORMATBAR_H__76705223_1E1F_11D1_830C_5CB0BB000000__INCLUDED_)
</FONT></TT></PRE>


<P>The code in the implementation file for CFormatBar now follows.

<PRE><TT><FONT COLOR="#990000">/////////////////////////////////////////////////////////////////////////////
// FormatBar.cpp : implementation file
//

#include "stdafx.h"
#include "RichEdit.h"
#include "FormatBar.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFormatBar

// Declare const array of font sizes
const static int nFontSizes[] = 
	{8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72};


CFormatBar::CFormatBar(UINT nID )
{
	nToolbarID = nID;
}

CFormatBar::~CFormatBar()
{
}


BEGIN_MESSAGE_MAP(CFormatBar, CToolBar)
	//{{AFX_MSG_MAP(CFormatBar)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
	ON_CBN_SELENDOK(IDC_FONTNAME, OnSelectFontName)
	ON_CBN_SELENDOK(IDC_FONTSIZE, OnSelectFontSize)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFormatBar message handlers

int CFormatBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CToolBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Load the toolbar
	if( !LoadToolBar( nToolbarID ) )
		return -1;


	// Get the average char width
	CClientDC dc(this);

	// Determine the size required by the font comboboxes
	// We will use the DEFAULT_GUI_FONT
	HGDIOBJ hFont = GetStockObject( DEFAULT_GUI_FONT );
	CFont font;
	font.Attach( hFont );
	dc.SelectObject( font );

	TEXTMETRIC tm;
	dc.GetTextMetrics( &tm );
	int cxChar = tm.tmAveCharWidth;
	int cyChar = tm.tmHeight + tm.tmExternalLeading;


	// Create the Font Name combo
	CRect rect; 
	GetItemRect( CommandToIndex(IDC_FONTNAME), &rect );
	rect.right = rect.left + (LF_FACESIZE+4)*cxChar;
	rect.bottom = rect.top + 16*cyChar;

	SetButtonInfo( CommandToIndex(IDC_FONTNAME), IDC_FONTNAME, 
				TBBS_SEPARATOR, rect.Width() );

	UINT nCreateStyle = WS_TABSTOP|WS_VISIBLE|WS_VSCROLL;
	if (!m_cmbFontName.Create(nCreateStyle|CBS_DROPDOWNLIST|CBS_SORT, 
		rect, this, IDC_FONTNAME))
	{
		TRACE0("Failed to create Font Name combo-box\n");
		return -1;
	}


	// Create Font Size combo
	GetItemRect( CommandToIndex(IDC_FONTSIZE), &rect );
	rect.right = rect.left + 10*cxChar;
	rect.bottom = rect.top + 16*cyChar;

	SetButtonInfo( CommandToIndex(IDC_FONTSIZE), IDC_FONTSIZE, 
				TBBS_SEPARATOR, rect.Width() );

	if (!m_cmbFontSize.Create(nCreateStyle|CBS_DROPDOWN|WS_HSCROLL, 
		rect, this, IDC_FONTSIZE))
	{
		TRACE0("Failed to create Font Size combo-box\n");
		return -1;
	}
	m_cmbFontSize.LimitText(4);


	// Set the font for the combo boxes to DEFAULT_GUI_FONT
	m_cmbFontName.SetFont(&font);
	m_cmbFontSize.SetFont(&font);

	// Fill the Font names in the Font Name combo
	::EnumFontFamilies( dc.m_hDC, NULL, (FONTENUMPROC)EnumFontFamProc, 
				(LPARAM) this );

	// Fill the Font Size combo
	CString sSize;
	int nSizeCount = sizeof(nFontSizes) / sizeof(nFontSizes[0]);
	for( int i=0; i < nSizeCount; i++ )
	{
		sSize.Format("%d", nFontSizes[i] );
		m_cmbFontSize.AddString( sSize );
	}

	return 0;
}

int CALLBACK CFormatBar::EnumFontFamProc(ENUMLOGFONT *lpelf, NEWTEXTMETRIC *lpntm,
					int nFontType, LPARAM lParam)
{
	CFormatBar* pWnd = (CFormatBar*)lParam;

	// Add the font name to the combo
	pWnd->m_cmbFontName.AddString(lpelf->elfLogFont.lfFaceName);

	return 1;		// 1 to continue enumeration
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
337p粉嫩大胆色噜噜噜噜亚洲| 国产亲近乱来精品视频| 国产一区二区女| 一区二区三区日韩欧美| 久久综合五月天婷婷伊人| 色婷婷av一区二区三区之一色屋| 韩日av一区二区| 五月激情丁香一区二区三区| 中文字幕av资源一区| 日韩欧美国产不卡| 欧美性猛片xxxx免费看久爱| 丁香五精品蜜臀久久久久99网站 | 国内久久精品视频| 一区二区激情视频| 国产精品午夜春色av| 91麻豆精品国产自产在线观看一区| 99国产精品久久| 国产91富婆露脸刺激对白| 久久精品国产精品亚洲精品| 亚洲国产毛片aaaaa无费看| 亚洲欧洲另类国产综合| 2020国产精品| 精品国产一区二区精华| 欧美福利视频一区| 欧美色视频在线| 在线免费观看不卡av| 暴力调教一区二区三区| 国产九色sp调教91| 久久99最新地址| 丝袜国产日韩另类美女| 午夜私人影院久久久久| 亚洲精品乱码久久久久久黑人| 亚洲国产高清不卡| 久久久不卡影院| 久久在线免费观看| 久久久久亚洲综合| 337p粉嫩大胆噜噜噜噜噜91av | 一区二区高清视频在线观看| 日韩一区在线免费观看| 中文字幕不卡的av| 国产精品福利一区二区| 国产精品欧美极品| 亚洲视频图片小说| 亚洲精品国产视频| 一区二区三区精品在线观看| 有坂深雪av一区二区精品| 亚洲欧美日韩久久| 一区二区三区精品视频在线| 亚洲国产aⅴ成人精品无吗| 午夜精品福利一区二区三区av | 国产69精品一区二区亚洲孕妇| 国产不卡一区视频| 福利一区福利二区| 99热在这里有精品免费| 色呦呦一区二区三区| 欧洲一区二区三区在线| 欧美日韩三级视频| 日韩午夜小视频| 欧美精品一区二区在线观看| 国产欧美视频一区二区三区| 亚洲视频每日更新| 亚洲va天堂va国产va久| 久久国内精品视频| 福利一区福利二区| 欧洲人成人精品| 欧美一二三区精品| 国产欧美日韩另类一区| 亚洲精品成人在线| 日韩精品福利网| 国产精品一二三四五| 色拍拍在线精品视频8848| 欧美日韩精品是欧美日韩精品| 日韩手机在线导航| 中文字幕日韩av资源站| 日日夜夜一区二区| 国产成人亚洲综合a∨猫咪| 91美女精品福利| 欧美白人最猛性xxxxx69交| 国产精品三级av| 日韩激情视频网站| 国产91在线观看| 欧美亚男人的天堂| 久久噜噜亚洲综合| 亚洲午夜精品网| 麻豆精品视频在线观看| 91在线porny国产在线看| 3atv在线一区二区三区| 国产精品国模大尺度视频| 日精品一区二区三区| 国产999精品久久久久久绿帽| 欧美精品色综合| 成人欧美一区二区三区小说 | 欧美在线你懂得| 久久久五月婷婷| 亚洲国产精品天堂| caoporm超碰国产精品| 欧美一级高清片| 亚洲免费在线视频一区 二区| 美女尤物国产一区| 欧美亚洲动漫另类| 国产精品福利影院| 国产一区二区女| 91精品国产综合久久婷婷香蕉 | 欧美日韩亚洲丝袜制服| 国产喂奶挤奶一区二区三区| 亚洲va天堂va国产va久| 99久久er热在这里只有精品66| 日韩精品在线网站| 亚洲成人免费看| 色婷婷av一区二区三区gif| 亚洲国产精品99久久久久久久久| 久久福利资源站| 欧美二区三区91| 亚洲激情图片小说视频| 成人国产一区二区三区精品| 精品av综合导航| 蜜臀久久久99精品久久久久久| 欧美日韩国产小视频| 综合自拍亚洲综合图不卡区| 国产成人精品免费| 久久久国产精品不卡| 久久精品国产亚洲一区二区三区| 欧美日韩国产在线播放网站| 亚洲综合一区在线| 色综合天天综合狠狠| 国产精品久久久久aaaa樱花 | 欧美极品美女视频| 国产精品一级在线| 精品国产乱码久久久久久图片| 免费在线欧美视频| 91精品国产综合久久小美女| 亚洲国产视频一区| 欧美视频一区二区三区在线观看| 亚洲精品国久久99热| 91九色02白丝porn| 亚洲国产日韩在线一区模特 | 日韩三级精品电影久久久 | 亚洲国产精品av| 成人午夜伦理影院| 国产精品久久久久久久午夜片| 国产99久久久精品| 亚洲欧美综合色| 91在线视频免费91| 一区二区三区在线免费观看| 在线观看视频91| 亚洲成人av电影| 日韩欧美第一区| 国产一区免费电影| 国产精品日韩成人| 色欧美片视频在线观看| 亚洲一区在线视频观看| 欧美无乱码久久久免费午夜一区 | 欧美美女黄视频| 日韩福利视频网| 日韩久久久久久| 韩国欧美国产一区| 国产精品成人在线观看| 色综合久久中文综合久久97| 亚洲一区二区免费视频| 日韩欧美久久一区| 高清视频一区二区| 亚洲精品国产精华液| 91精品国产91久久久久久一区二区 | 色综合网站在线| 午夜欧美在线一二页| 精品国产91亚洲一区二区三区婷婷 | 337p亚洲精品色噜噜| 久久97超碰色| 亚洲欧美日韩国产中文在线| 欧美久久一二三四区| 国产一区91精品张津瑜| 亚洲欧洲综合另类| 日韩欧美卡一卡二| 成人精品视频一区二区三区 | 久久新电视剧免费观看| 北岛玲一区二区三区四区| 亚洲gay无套男同| 久久久www成人免费无遮挡大片 | 精品久久久三级丝袜| av成人动漫在线观看| 日韩精品欧美成人高清一区二区| 亚洲国产高清在线观看视频| 欧美日韩国产成人在线91| 国产精品性做久久久久久| 夜夜夜精品看看| 国产视频一区二区在线| 欧美精品一级二级三级| 不卡的av中国片| 狠狠网亚洲精品| 亚洲小少妇裸体bbw| 国产午夜精品福利| 91精品欧美福利在线观看| 97久久精品人人澡人人爽| 久久66热re国产| 亚洲电影激情视频网站| 中文字幕一区在线观看| 久久综合九色综合欧美就去吻 | 黑人巨大精品欧美一区| 一区二区三区四区国产精品| 久久久亚洲综合|