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

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

?? formatbar.shtml

?? mfc資源大全包含MFC編程各個方面的源碼
?? SHTML
?? 第 1 頁 / 共 2 頁
字號:
void CFormatBar::OnSelectFontName()
{
	TCHAR szFontName[LF_FACESIZE];
	int nIndex = m_cmbFontName.GetCurSel();
	m_cmbFontName.GetLBText( nIndex, szFontName );

	// If font name is empty - return
	if( szFontName[0] == 0 )
		return;

	CHARNMHDR fh;
	CHARFORMAT& cf = fh.cf;
	fh.hwndFrom = m_hWnd;
	fh.idFrom = GetDlgCtrlID();
	fh.code = FN_SETFORMAT;
	cf.dwMask = CFM_FACE;

	_tcsncpy(cf.szFaceName, szFontName, LF_FACESIZE);	//strncpy

	GetOwner()->SendMessage(WM_NOTIFY, fh.idFrom, (LPARAM)&fh);
}

void CFormatBar::OnSelectFontSize()
{
	TCHAR szSize[5];
	int index = m_cmbFontSize.GetCurSel();
	if( index != CB_ERR )
		m_cmbFontSize.GetLBText(index, szSize );
	else
		m_cmbFontSize.GetWindowText( szSize, 5 );

	// Get size in Twips
	int nSize = _ttoi( szSize ) * 20;			// atoi for tchar

	if( !nSize )
		return;

	CHARNMHDR fh;
	CHARFORMAT& cf = fh.cf;
	fh.hwndFrom = m_hWnd;
	fh.idFrom = GetDlgCtrlID();
	fh.code = FN_SETFORMAT;

	cf.dwMask = CFM_SIZE;
	cf.yHeight = nSize;

	GetOwner()->SendMessage(WM_NOTIFY, fh.idFrom, (LPARAM)&fh);
}

void CFormatBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
	// Take care of the regular toolbar buttons
	CToolBar::OnUpdateCmdUI( pTarget, bDisableIfNoHndler);

	// Don't update the combo boxes if user changing font attribute
	CWnd *pWnd = GetFocus();
	if( pWnd == &m_cmbFontName || m_cmbFontSize.IsChild(pWnd) )
		return;

	// get the current font from the view and update
	CHARNMHDR fh;
	CHARFORMAT& cf = fh.cf;
	fh.hwndFrom = m_hWnd;
	fh.idFrom = GetDlgCtrlID();
	fh.code = FN_GETFORMAT;

	CWnd *pOwnerWnd = GetOwner();
	if( !GetOwner()->SendMessage(WM_NOTIFY, fh.idFrom, (LPARAM)&fh) )
	{
		TRACE0("The Rich Edit View/Control has to handle the FN_GETFORMAT\n"
			"notification for the Format Bar to work properly\n");
		return;
	}

	// Update the font only if the selection font is different
	TCHAR szName[LF_FACESIZE];
	m_cmbFontName.GetWindowText( szName, LF_FACESIZE );

	// the selection must be same font and charset to display correctly
	if ((cf.dwMask & (CFM_FACE|CFM_CHARSET)) != (CFM_FACE|CFM_CHARSET))
		m_cmbFontName.SetCurSel( -1 );
	else if( ::_tcscmp( szName, cf.szFaceName ) != 0 )
	{
		if( m_cmbFontName.SelectString( -1, cf.szFaceName ) == CB_ERR )
			m_cmbFontName.SetCurSel( -1 );
	}


	// Update the font size
	TCHAR szSize[5];
	m_cmbFontSize.GetWindowText( szSize, 5 );
	int nSize = _ttoi( szSize );				// atoi for tchar

	// Update the font size only if selection is different 
	int nSelSize = (cf.dwMask & CFM_SIZE) ? cf.yHeight/20 : 0;
	if( nSize != nSelSize )
	{
		if(cf.dwMask & CFM_SIZE)
		{
			CString strSize;
			strSize.Format("%d", nSelSize );
			m_cmbFontSize.SetWindowText( strSize );
		}
		else
			m_cmbFontSize.SetCurSel(-1);
	}
}

BOOL CFormatBar::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN)
	{
		NMHDR nm;
		nm.hwndFrom = m_hWnd;
		nm.idFrom = GetDlgCtrlID();
		nm.code = NM_RETURN;
		switch (pMsg->wParam)
		{
		case VK_RETURN:
			// Send change notification
			if( m_cmbFontName.IsChild(GetFocus()) )
				OnSelectFontName();
			else if( m_cmbFontSize.IsChild(GetFocus()) )
				OnSelectFontSize();
			//Fall through
		case VK_ESCAPE:
			GetOwner()->SendMessage(WM_NOTIFY, nm.idFrom, (LPARAM)&nm);
			return TRUE;
		}
	}
	
	return CToolBar::PreTranslateMessage(pMsg);
}
</FONT></TT></PRE>


<P>At the top of the file, the nFontSizes array is declared. This array is initialized to the commonly used font sizes and is used to initialize the font size combobox. To make the design simple, the CFormatBar class has beed designed so that the user is always provided with this list of sizes even though the font may not support all of these sizes. The user can also type in an arbitrary value for the font size.

<P>The OnCreate() function  calls the base class version of the function so that the toolbar gets created. It then loads the toolbar from the resource and creates the two comboboxes - for font name and font size. To make place for the comboboxes, the place holder buttons are resized using the SetButtonInfo() function. We use the font that will be used in the combobox to determine a reasonable width for the control. Since a font name can have at most LF_FACESIZE characters, we use this number and the average width of a character to determine the width of the font name combobox. LF_FACESIZE by the way is a constant defined as 32. Similarly we make the font size combobox wide enough to accommodate 4 characters. 

<P>The font name combobox is created with the CBS_DROPDOWNLIST style. This style forces the user to select one of the listed styles. You may want to change this style to CBS_DROPDOWN so that the user may specify a font that may not be available on the machine. The font size combobox uses the CBS_DROPDOWN style to allow the user to type in any point size or select from the list.

<P>At the end, the OnCreate() function populates the font size combobox by calling the EnumFontFamilies() function, which in turn calls the EnumFontFamProc() for each font on the system (the screen device context). It is EnumFontFamProc() that actually adds the font names to the combobox. OnCreate() also populates the font size combobox from the array of common font sizes.

<P>The OnSelectFontName() is called when the user selects a list item in the font name combobox. Notice the entry ON_CBN_SELENDOK(IDC_FONTNAME, OnSelectFontName) in the message map hooking up this function. This function is also called when the user hits the enter key. The purpose of this function is to send out a notification so that the rich edit control can be updated. It uses an extended notification header so that it can also pass on the character format information. Note that it uses a custom notification code. It is the responsibility of the rich edit control class to handle this notification and change the format accordingly. Similarly, the OnSelectFontSize() handles the font size combobox.

<P>The OnUpdateCmdUI() function is called by the framework to update the status of the toolbar. We override this function because the Format Bar has the two comboboxes. The toolbar buttons get updated by the regular ON_UPDATE_COMMAND_UI() message map macros but the combobox needs special handling. This function basically gets the font information about the current selection from the rich edit control and updates the font comboboxes. This of course doesn't make sense if the user is trying to change the font. The function, therefore returns immediately if either of the comboboxes have the input focus. Here again a custom notification is sent out. The FN_GETFORMAT should be handled by the rich edit control and the control should return the format information through the notification header structure.

<P>Overriding the PreTranslateMessage() is how we tackle the situation when the user presses the enter or the escape key. When the user presses the enter key, it calls the OnSelectFontName() or the OnSelectFontSize() function, whichever is appropriate. The function then sends the NM_RETURN notification. This is another notification that the rich edit control has to look out for. On receiving this message, the rich edit control should take back the input focus.

<H4>Step 3: Create the Format toolbar</H4>
To create the format toolbar, first add a CFormatBar member variable in the CMainFrame class. Actually any frame class that will contain the CRichEditView or CRichEditCtrl will do.

<PRE><TT><FONT COLOR="#990000">protected:  // control bar embedded members
	CFormatBar	m_wndFormatBar;
</FONT></TT></PRE>

<P>Create the format toolbar in the OnCreate() function. Here's sample code that does that. 

<PRE><TT><FONT COLOR="#990000">int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndFormatBar.Create(this, WS_CHILD | WS_VISIBLE |
			CBRS_TOP |CBRS_TOOLTIPS|CBRS_FLYBY,
			IDR_FORMATBAR) )
	{
		TRACE0("Failed to create FormatBar\n");
		return -1;      // fail to create
	}
	m_wndFormatBar.SetWindowText( _T("Format") );
	m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar( &m_wndFormatBar );

	:
	:
	:	

	return 0;
}
</FONT></TT></PRE>

<H4>Step 4: Add handlers for format toolbar notifications</H4>
As we have already covered, the CFormatBar sends a couple of custom notification as well as the NM_RETURN notification. These notifications inform the rich edit control about activities on the toolbar. The Class Wizard won't be able to help you add these handlers, so you would have to add the entries to the message map yourself.

<PRE><TT><FONT COLOR="#990000">BEGIN_MESSAGE_MAP(CMyRichEditView, CRichEditView)
	//{{AFX_MSG_MAP(CMyRichEditView)
	:
	:
	//}}AFX_MSG_MAP
	ON_NOTIFY(FN_GETFORMAT, IDR_FORMATBAR, OnGetCharFormat)
	ON_NOTIFY(FN_SETFORMAT, IDR_FORMATBAR, OnSetCharFormat)
	ON_NOTIFY(NM_RETURN, IDR_FORMATBAR, OnBarReturn)
END_MESSAGE_MAP()
</FONT></TT></PRE>


<P>The implementation of the handler functions are quite simple. The OnGetCharFormat() function simply gets the format of the current selection and returns this through the notification header. The OnSetCharFormat() receives the format information through the notification header and applies it to the current selection. The OnBarReturn() simply sets focus to the rich edit control.

<PRE><TT><FONT COLOR="#990000">void CMyRichEditView::OnGetCharFormat(NMHDR* pNMHDR, LRESULT* pRes)
{
	((CHARNMHDR*)pNMHDR)->cf = GetCharFormatSelection();
	*pRes = 1;
}

void CMyRichEditView::OnSetCharFormat(NMHDR* pNMHDR, LRESULT* pRes)
{
	SetCharFormat(((CHARNMHDR*)pNMHDR)->cf);
	*pRes = 1;
}

void CMyRichEditView::OnBarReturn(NMHDR*, LRESULT* )
{
	SetFocus();
}
</FONT></TT></PRE>

<H4>Step 5: Add UPDATE_COMMAND_UI & COMMAND handlers</H4>
The CRichEditView class already provides support for all but one of the remaining format toolbar buttons. So all we need to do is hook up the message map entries so that the proper functions get called. The only function that we have to write is for the color button. The message map entries and the OnColorPick() function is shown below. We do not have to write the other functions since they are already defined in CRichEditView.

<PRE><TT><FONT COLOR="#990000">BEGIN_MESSAGE_MAP(CMyRichEditView, CRichEditView)
	//{{AFX_MSG_MAP(CMyRichEditView)
	:
	:
	ON_COMMAND(ID_CHAR_COLOR, OnColorPick)
	ON_COMMAND(ID_CHAR_BOLD, OnCharBold)
	ON_UPDATE_COMMAND_UI(ID_CHAR_BOLD, OnUpdateCharBold)
	ON_COMMAND(ID_CHAR_ITALIC, OnCharItalic)
	ON_UPDATE_COMMAND_UI(ID_CHAR_ITALIC, OnUpdateCharItalic)
	ON_COMMAND(ID_CHAR_UNDERLINE, OnCharUnderline)
	ON_UPDATE_COMMAND_UI(ID_CHAR_UNDERLINE, OnUpdateCharUnderline)
	ON_COMMAND(ID_PARA_CENTER, OnParaCenter)
	ON_UPDATE_COMMAND_UI(ID_PARA_CENTER, OnUpdateParaCenter)
	ON_COMMAND(ID_PARA_LEFT, OnParaLeft)
	ON_UPDATE_COMMAND_UI(ID_PARA_LEFT, OnUpdateParaLeft)
	ON_COMMAND(ID_PARA_RIGHT, OnParaRight)
	ON_UPDATE_COMMAND_UI(ID_PARA_RIGHT, OnUpdateParaRight)
	ON_COMMAND(ID_INSERT_BULLET, OnBullet)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


void CMyRichEditView::OnColorPick() 
{
	CColorDialog dlg;

	if( dlg.DoModal() == IDOK ){
		CRichEditView::OnColorPick(dlg.GetColor());
	}
}
</FONT></TT></PRE>











<P>
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="http://www.codeguru.com">Goto HomePage</A></FONT></TD>

<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>&copy; 1998 Zafir Anjum</FONT>&nbsp;</CENTER>
</TD>

<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact me: <A HREF="mailto:zafir@home.com">zafir@home.com</A>&nbsp;</FONT></DIV>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人欧美一区二区三区小说| 91蜜桃视频在线| 日韩电影在线观看网站| 亚洲一区二区三区中文字幕在线| 亚洲情趣在线观看| 综合久久给合久久狠狠狠97色| 中文一区二区在线观看| 中国色在线观看另类| 亚洲日本中文字幕区| 亚洲午夜电影在线观看| 全部av―极品视觉盛宴亚洲| 免费不卡在线观看| 国产一区二区美女诱惑| av不卡免费电影| 91精品91久久久中77777| 欧美色综合网站| 日韩美女视频在线| 国产欧美一区二区精品性色超碰| 中文欧美字幕免费| 亚洲一区二区三区中文字幕| 日本91福利区| jiyouzz国产精品久久| 日本韩国精品一区二区在线观看| 欧美年轻男男videosbes| 欧美成人精品高清在线播放| 国产片一区二区| 一区二区三区在线观看欧美| 久久精品久久99精品久久| 丁香网亚洲国际| 欧美午夜宅男影院| 精品国产麻豆免费人成网站| 国产精品福利影院| 日韩成人免费电影| 成人av资源在线观看| 欧美另类久久久品| 国产精品色眯眯| 天天影视涩香欲综合网| 成人app下载| 日韩欧美中文字幕制服| 自拍偷拍欧美精品| 九九热在线视频观看这里只有精品| 97久久久精品综合88久久| 日韩三级伦理片妻子的秘密按摩| 亚洲欧美日韩国产中文在线| 久久精品99国产精品| 欧美在线看片a免费观看| 2020国产精品| 免费欧美高清视频| 欧美日韩一区二区欧美激情| 国产精品网友自拍| 国产一区二区在线电影| 欧美系列亚洲系列| 亚洲精品免费电影| 成人免费看片app下载| 欧美xingq一区二区| 午夜精品久久久久久久久久| 色综合色综合色综合 | 欧美日韩精品三区| 日韩一区日韩二区| 国产91对白在线观看九色| 日韩欧美一级精品久久| 亚洲成人午夜影院| 欧美性欧美巨大黑白大战| 国产精品久久久久久久久久免费看 | 日韩不卡手机在线v区| 91在线观看美女| 亚洲同性gay激情无套| 不卡视频在线看| 国产精品理伦片| 成人免费视频一区二区| 欧美激情综合在线| 国产91精品免费| 中文字幕一区二区三区四区不卡 | 在线观看中文字幕不卡| 国产精品高清亚洲| 色综合天天狠狠| 曰韩精品一区二区| 欧美日韩一区 二区 三区 久久精品 | 丝瓜av网站精品一区二区| 欧美性色aⅴ视频一区日韩精品| 亚洲欧美一区二区三区极速播放 | 91精品免费在线| 日韩成人精品视频| 精品国产123| 成人美女视频在线观看18| 国产精品全国免费观看高清| 9久草视频在线视频精品| 亚洲区小说区图片区qvod| 欧美视频三区在线播放| 热久久一区二区| 日本一区二区三区在线不卡| 成人app网站| 午夜成人免费电影| 久久男人中文字幕资源站| 成人午夜大片免费观看| 一区二区不卡在线视频 午夜欧美不卡在| 日本韩国欧美三级| 久久99精品国产麻豆婷婷| 久久久国产午夜精品 | 日韩avvvv在线播放| 久久综合色鬼综合色| jlzzjlzz欧美大全| 午夜精品久久久| 国产人伦精品一区二区| 在线观看亚洲成人| 国产一区二区精品在线观看| 亚洲品质自拍视频网站| 精品国产91洋老外米糕| 在线免费观看日韩欧美| 久久99最新地址| 夜夜亚洲天天久久| 久久亚洲影视婷婷| 欧美日韩国产一级片| 成人三级伦理片| 美洲天堂一区二卡三卡四卡视频| 中文一区二区在线观看| 日韩一区二区视频在线观看| 成人18视频日本| 激情久久五月天| 亚洲一卡二卡三卡四卡| 欧美国产激情一区二区三区蜜月| 欧美三区免费完整视频在线观看| 成人性色生活片| 韩国一区二区在线观看| 五月婷婷色综合| 亚洲一区二区三区精品在线| 中文字幕欧美激情| 久久伊人中文字幕| 日韩欧美高清一区| 欧美精品三级日韩久久| 色综合激情五月| av色综合久久天堂av综合| 国产一区二区三区av电影| 久久精品国产精品青草| 图片区小说区国产精品视频| 亚洲激情综合网| 亚洲视频免费在线观看| 最好看的中文字幕久久| 国产精品久久久久久久第一福利| 久久影院视频免费| 久久久久高清精品| 国产偷国产偷精品高清尤物| 日韩欧美国产wwwww| 日韩欧美视频一区| 日韩一区二区在线看| 欧美一区二区国产| 欧美videos大乳护士334| 欧美一区二区三区婷婷月色| 91精品国产综合久久久久久漫画| 欧美少妇一区二区| 制服丝袜亚洲精品中文字幕| 欧美日韩激情在线| 日韩一区二区三区av| 日韩三级.com| 久久久久久亚洲综合| 国产欧美一区二区在线| 国产精品传媒视频| 樱花影视一区二区| 亚洲一二三四在线| 麻豆免费精品视频| 国产一区美女在线| 丁香啪啪综合成人亚洲小说 | 成人成人成人在线视频| eeuss鲁片一区二区三区| 91麻豆国产自产在线观看| 欧美午夜精品一区二区三区| 这里只有精品免费| 久久久夜色精品亚洲| 中文字幕亚洲在| 香蕉成人啪国产精品视频综合网| 美女脱光内衣内裤视频久久影院| 久久99精品视频| 97久久精品人人爽人人爽蜜臀| 欧美在线小视频| 精品国产亚洲一区二区三区在线观看| 久久久五月婷婷| 亚洲免费视频成人| 免费在线看一区| av亚洲精华国产精华精| 精品污污网站免费看| 久久亚洲精华国产精华液| 亚洲天堂中文字幕| 蜜桃av噜噜一区| 91亚洲精品久久久蜜桃网站| 欧美美女视频在线观看| 久久伊99综合婷婷久久伊| 一区二区三区在线观看国产| 久久精品99国产精品日本| 91丝袜美女网| 欧美成人伊人久久综合网| 亚洲人亚洲人成电影网站色| 看国产成人h片视频| 日本高清不卡视频| 久久蜜桃av一区二区天堂| 亚洲成a天堂v人片| 不卡视频在线观看| 亚洲精品在线电影| 天天影视网天天综合色在线播放 | 国产一区在线观看视频| 色综合久久久久综合体桃花网|