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

📄 adv_copypaste.shtml

📁 mfc资源大全包含MFC编程各个方面的源码
💻 SHTML
📖 第 1 页 / 共 2 页
字号:
<li><b>\ul</b> - Enable Underline (scoped within a group)
</ul>

<P>For example the RTF string:
<PRE><TT><FONT COLOR="#990000">
{\rtf1 {1 \tab 2 \tab 3 \par 4 \tab {\b\i 5} \tab 6}}
</FONT></TT></PRE>

<P>Would product the following formatted text:
<pre><b>
1 	2 	3 
4 	5 	6
</b></pre>

<P>That might not be terribly exciting, but it does give you more formatting options than CF_TEXT. 
<P>Don't forget that when you embed the backslash ('\') character in a C++ string you need to prepend it with another backslash. 
<P>The actual format value is found using the following code:
<PRE><TT><FONT COLOR="#990000">UINT rtfformat = ::RegisterClipboardFormat(CF_RTF);
</FONT></TT></PRE>

<H4>CF_BITMAP</H4>
Randy More's article (<A HREF="http://www.codeguru.com/clipboard/bitmap_to_clipboard.shtml">http://www.codeguru.com/clipboard/bitmap_to_clipboard.shtml</A>) discusses how to create and place a CF_BITMAP object the clipboard. I won't revisit that here, but the following example shows how to use the technique Randy described with Delayed Rendering.

<P><b>Table 4 - Delayed Rendering a CBitmap</b>
<PRE><TT><FONT COLOR="#990000">
BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium)
	{
		if (lpFormatEtc->cfFormat == CF_BITMAP) {
			CBitmap bitmap;
			CClipExamView*	pView =  (CClipExamView*) ((CFrameWnd*)(AfxGetApp()->m_pMainWnd))->GetActiveView();
	
			TRACE("Output CF_BITMAP\r\n");
			if (pView != NULL) {
				CClientDC cdc(pView);	
				CDC dc;
				dc.CreateCompatibleDC(&cdc);	
					
				CRect bounds;
				
				pView->GetClientRect(&bounds);
			
				bitmap.CreateCompatibleBitmap(&cdc, bounds.Width(), bounds.Height());
				CBitmap* oldBitmap = dc.SelectObject(&bitmap);	
			
				CBrush fill(RGB(255, 255, 255));
				dc.FillRect(bounds, &fill);	
			
				dc.TextOut(0, 0, CString(_T("Bitmap")));
				pView->OnDraw(&dc);	
						
				lpStgMedium->tymed = TYMED_GDI;	
				lpStgMedium->hBitmap = HBITMAP(bitmap);

				bitmap.Detach();
			
				dc.SelectObject(oldBitmap);
				return TRUE;
			}
			return FALSE;
		} 
		return COleDataSource::OnRenderData(lpFormatEtc, lpStgMedium);
	}
</FONT></TT></PRE>

<H4>CF_ENHMETAFILE</H4>
Randy More's article (<A HREF="http://www.codeguru.com/clipboard/emf_to_clipboard.shtml">http://www.codeguru.com/clipboard/emf_to_clipboard.shtml</A>) discusses how to create and place a CF_ENHMETAFILE object the clipboard. I won't revisit that here, but the following code example shows how to use the technique Randy described with Delayed Rendering.

<P><b>Table 5 - Delayed Rendering a Metafile</b>
<PRE><TT><FONT COLOR="#990000">	BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium)
	{
		if (lpFormatEtc->cfFormat == CF_ENHMETAFILE) {
			CClipExamView*	pView =  (CClipExamView*) ((CFrameWnd*)(AfxGetApp()->m_pMainWnd))->GetActiveView();
			TRACE("Output CF_ENHMETAFILE\r\n");
			if (pView != NULL) {
				CClientDC dcRef(pView);
				CMetaFileDC dcMeta;
					
				CRect lmbr;	
				pView->GetClientRect(lmbr);
					
				dcMeta.CreateEnhanced(&dcRef, NULL, NULL,"Metafile\0Copy\0\0" );
				dcMeta.SetMapMode(MM_TEXT);	
			
				CBrush fill(RGB(255, 255, 255));
				dcMeta.FillRect(lmbr,&fill);
				dcMeta.TextOut(0, 0, CString(_T("Metafile")));
			
				pView->OnDraw(&dcMeta);
			
				lpStgMedium->hEnhMetaFile = dcMeta.CloseEnhanced();
				lpStgMedium->tymed = TYMED_GDI;
					
				return TRUE;
			}
			return FALSE;
		} 
		return COleDataSource::OnRenderData(lpFormatEtc, lpStgMedium);
	}
</FONT></TT></PRE>

<H3>Clipboard Preference</H3>
The following table shows the preference order for the five most popular clipboard formats into MS-Office applications. Please notice that the preferences are often different between a Drag/Drop and a Cut/Copy/Paste. 

<P><b>Table 6 - MS-Office Clipboard Preferences</b>
<TABLE BORDER CELLSPACING=1 CELLPADDING=7 WIDTH=612>
<TR><TD WIDTH="18%" VALIGN="TOP" ROWSPAN=2>
<B><FONT><P ALIGN="CENTER">Format</B></FONT></TD>
<TD WIDTH="26%" VALIGN="TOP" COLSPAN=2>
<B><FONT><P ALIGN="CENTER">MS-Word 97</P>
<P ALIGN="CENTER">(To a blank page)</B></FONT></TD>
<TD WIDTH="27%" VALIGN="TOP" COLSPAN=2>
<B><FONT><P ALIGN="CENTER">MS-Excel 97</P>
<P ALIGN="CENTER">(To a blank workbook)</B></FONT></TD>
<TD WIDTH="28%" VALIGN="TOP" COLSPAN=2>
<B><FONT><P ALIGN="CENTER">MS-PowerPoint 97</P>
<P ALIGN="CENTER">(To a blank slide)</B></FONT></TD>
</TR>
<TR><TD WIDTH="12%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Drag/Drop</B></FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Cut/Copy/Paste</B></FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Drag/Drop</B></FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Cut/Copy/Paste</B></FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Drag/Drop</B></FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<B><FONT><P ALIGN="CENTER">Cut/Copy/Paste</B></FONT></TD>
</TR>
<TR><TD WIDTH="18%" VALIGN="TOP">
<FONT FACE="Courier New" SIZE=1><P ALIGN="CENTER">CF_BITMAP</FONT></TD>
<TD WIDTH="12%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">3</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">4</FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">4</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
</TR>
<TR><TD WIDTH="18%" VALIGN="TOP">
<FONT FACE="Courier New" SIZE=1><P ALIGN="CENTER">CF_ENHMETAFILE</FONT></TD>
<TD WIDTH="12%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">3</FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">3</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
</TR>
<TR><TD WIDTH="18%" VALIGN="TOP">
<FONT FACE="Courier New" SIZE=1><P ALIGN="CENTER">CF_RTF</FONT></TD>
<TD WIDTH="12%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">3</FONT></TD>
</TR>
<TR><TD WIDTH="18%" VALIGN="TOP">
<FONT FACE="Courier New" SIZE=1><P ALIGN="CENTER">CF_TEXT</FONT></TD>
<TD WIDTH="12%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">1</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">4</FONT></TD>
</TR>
<TR><TD WIDTH="18%" VALIGN="TOP">
<FONT FACE="Courier New" SIZE=1><P ALIGN="CENTER">Csv</FONT></TD>
<TD WIDTH="12%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="13%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">2</FONT></TD>
<TD WIDTH="14%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
<TD WIDTH="15%" VALIGN="TOP">
<FONT><P ALIGN="CENTER">-</FONT></TD>
</TR>
</TABLE>

<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 + -