Advanced Copy/Paste '& Drag/Drop Support

Copyright © 1998, Keith Rule -This information is intended for personal use. It may not be reprinted or republished without permission of the author.

Introduction

One of the intentions of the clipboard infrastructure in MS-Windows is to allow nearly seamless interaction between applications. However, neither Microsoft nor the reams of programming books available, seriously discuss the issue of seamless interchange of data with MS-Office products. I personally feel this is an unfortunate omission, which requires developers to spend a fair amount of time hunting for information, and/or doing trial-and-error experiments.

This article address several issues around interchanging data with MS-Office Products. The major topics addressed are:

  • Placing Multiple formats on the Clipboard.
  • Delayed Rendering.
  • A survey of common clipboard.
  • The preference of several common target applications (MS-Word, MS-Excel, and MS-PowerPoint).

This article assumes a basic understanding of using the clipboard with MFC. If you are unfamiliar with the basic use of the clipboard, please read the article Basic Copy/Paste & Drag/Drop Support

Placing Multiple Formats on the Clipboard

A fundamental issue when initiating a drag/cut/copy is that there is no way to know what target application will be the destination. This is a problem when the information you would like MS-Word to accept is different from the information you would like MS-Excel to accept.

This issue is resolved in two ways:

  • The application that initiates the drag/cut/copy may place more than one clipboard format on the clipboard.
  • The target often accepts more than one format, but has a preference (meaning a acceptance order) for the formats it accepts.

Table 6 shows the acceptance order for Cut/Copy/Paste and Drag/Drop in MS-Excel, MS-Word, and MS-PowerPoint. MS-Excel accepts the format "Csv", while neither MS-Word or MS-PowerPoint accept that format.

If you would like MS-Word to accept data that is different from what you would like to MS-Excel to accept, all you need to do is place both an RTF representation and a Csv representation on the clipboard. Since MS-Excel doesn't accept RTF it will get the Csv data, and since MS-Word doesn't accept Csv it will get the RTF data.

You can often exploit these differences to get the Cut/Copy/Paste and Drag/Drop behavior you desire.

The code example in Table 1 shows how both RTF and Csv formats can be placed on the clipboard at once. Table 2 and 3 shows the result of using this code when this data is dragged to MS-Word and MS-Excel.

Table 1 - Source for initiating RTF and Csv clipboard formats

void CClipExamView::Word2Clipboard(COleDataSource * pSource)
{
	UINT format = ::RegisterClipboardFormat(_T("Rich Text Format"));
	CSharedFile	sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
	CString		text = _T("{\\rtf1 {1\\tab 2\\tab 3\\par 4\\tab }{\\b\\i 5}{\\tab 6\\par}}");

	sf.Write(text, text.GetLength());

	HGLOBAL hMem = sf.Detach();
	if (!hMem) return;
	pSource->CacheGlobalData(format, hMem);
}

void CClipExamView::Excel2Clipboard(COleDataSource * pSource)
{
	UINT format = ::RegisterClipboardFormat(_T("Csv"));
	CSharedFile	sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
	CString		text = _T("6,5,4\n2,=1+1,1");

	sf.Write(text, text.GetLength());

	HGLOBAL hMem = sf.Detach();
	if (!hMem) return;
	pSource->CacheGlobalData(format, hMem);
}

void CClipExamView::OnEditCopy() 
{
	COleDataSource	source;
	Excel2Clipboard(&source);
	Word2Clipboard(&source);
	source.SetClipboard();
}

void CClipExamView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	COleDataSource*	pSource = new COleDataSource();
	Excel2Clipboard(pSource);
	Word2Clipboard(pSource);
	pSource->DoDragDrop();
}


Table 2 - Excel as the Drop Target

Table 3 - Word as the Drop Target

It's obvious from looking at the screen shots that the text placed in Word was different than the text placed in Excel. You can exploit the clipboard format preferences of the target applications to get the behavior you wish on a drop.

Delayed Rendering

Delayed Rendering does what the name implies. It defers creating the data that goes on the clipboard until it is specifically asked from by the destination application.

The code examples shown so far have placed the entire format on the clipboard when the source application initiates the cut/copy or drag. This can needlessly consume a larger amount of shared memory and can consume time creating unused data that is placed on the clipboard.

If you plan to use the clipboard to move large amounts of data, you should use Delayed Rendering. This will make the performance of cut/copy/paste and drag/drop appear much better to the user.

Modifying COleDataSource for Delayed Rendering

To use Delayed Rendering you need to override one or more member functions in the COleDataSource class. By overriding the OnRenderGlobalData() member function you can intercept the target applications request for data and return whatever data you wish.

You check the requested format by looking at the lpFormatEtc->cfFormat item. If you find a format you accept you simply write your data to shared memory and place the handle in *phGlobal. Return TRUE if you've honored the request for data and FALSE if you didn't.

To specify the supported format when you initiate the cut/copy/drag you replace the CacheGlobalData() call with the DelayRenderData() call. This specifies the supported format without having to place the data for that format on the clipboard until requested by the target application.

Table 3 - A Derived COleDataSource class that supports Delayed Rendering

class CMyOleDataSource : public COleDataSource
{
public:
	// Called when target application requests data
	BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal)
	{
		if (lpFormatEtc->cfFormat == ::RegisterClipboardFormat("Csv")) {
			// Handle Csv format
			CSharedFile sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
			CString		text = _T("Excel2Clipboard\n6,5,4\n3,2,1");
			sf.Write(text, text.GetLength());
			HGLOBAL hMem = sf.Detach();
			*phGlobal = hMem;
			return (hMem != NULL);
		} else if (lpFormatEtc->cfFormat == ::RegisterClipboardFormat(CF_RTF)) {
			// Handle Rich Text Format
			CSharedFile sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
			CString		text = _T("{\\rtf1 {Word2Clipboard\\par 1\\tab 2\\tab 3\\par 4\\tab 5\\tab 6}}");
			sf.Write(text, text.GetLength());
			HGLOBAL hMem = sf.Detach();
			*phGlobal = hMem;
			return (hMem != NULL);
		} 
		
		return FALSE;
	}

	void SetClipboard()
	{
		// Place available formats on the clipboard
		DelayRenderData(::RegisterClipboardFormat("Csv"));
		DelayRenderData(::RegisterClipboardFormat(CF_RTF));

		// Initiate a cut/copy to the clipboard
		COleDataSource::SetClipboard();
	}

	DROPEFFECT DoDragDrop(DWORD dwEffects = DROPEFFECT_COPY|DROPEFFECT_MOVE|DROPEFFECT_LINK, LPCRECT lpRectStartDrag = NULL, COleDropSource* pDropSource = NULL)
	{
		// Place available formats on the clipboard
		DelayRenderData(::RegisterClipboardFormat("Csv"));
		DelayRenderData(::RegisterClipboardFormat(CF_RTF));

		// Initiate a drag to the clipboard
		return COleDataSource::DoDragDrop(dwEffects, lpRectStartDrag, pDropSource);
	}
};

In the example in Table 2, I've chosen to override the SetClipboard() and DoDragDrop() member functions so that I can specify the supported formats. This isn't necessary, but simplifies the usage of this class. As can be seen in Table 3.

Table 3 - An example using CMyOleDataSource.

void CClipExamView::OnEditCopy() 
{
	CMyOleDataSource source;
	source.SetClipboard();
}

void CClipExamView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CMyOleDataSource source;
	source.DoDragDrop();
}

Common Clipboard Formats

This section describes several commonly used clipboard formats. This is not intended to be an exhaustive list. However, it should be enough to get you started if you are not already familiar with these formats.

CF_TEXT

The CF_TEXT format is probably the most used of the clipboard formats commonly used by developers. This format simply defines a text string that is placed on the clipboard.

See http://www.codeguru.com/clipboard/copypaste_dragdrop.shtml for a simple example of how to read and write CF_TEXT from the clipboard.

If you plan to use the format with MS-Excel, keep in mind that tabs ('\t') separate the columns and new-lines ('\n') start a new row. In MS-Word new-lines denote the beginning of a new paragraph.

Csv

The "Csv" format stands for Comma Separated Values. "Csv" files are easy to export from an application and most Spreadsheets and Databases can import this format.

When using the "Csv" format with MS-Excel remember that commas (',') separate columns and new-lines ('\n') start a new row.

The actual format value is found using the following code:

UINT csvformat = ::RegisterClipboardFormat("Csv");

Other than the special format value, this format is a text string and can be created in the same manner as the CF_TEXT format.

Rich Text Format (CF_RTF)

This Rich Text Format is intended as an interchange format for Word-processing applications. Because of that, it is a rather large and feature rich file format. Luckily, it is possible to describe a minimal RTF command set for creating simple formatted documents.

An RTF document consists of a group with the following format:

{\rtf1  document contents }

The document content is one or more groups that contain plain text and control words. There are many more control words that can be documented here, so I will hit the high points.

  • \par - Starts a new paragraph.
  • \tab - A tab.
  • \b - Enable Bold (scoped within a group)
  • \i - Enable Italics (scoped within a group)
  • \ul - Enable Underline (scoped within a group)

For example the RTF string:

{\rtf1 {1 \tab 2 \tab 3 \par 4 \tab {\b\i 5} \tab 6}}

Would product the following formatted text:


1 	2 	3 
4 	5 	6

That might not be terribly exciting, but it does give you more formatting options than CF_TEXT.

Don't forget that when you embed the backslash ('\') character in a C++ string you need to prepend it with another backslash.

The actual format value is found using the following code:

UINT rtfformat = ::RegisterClipboardFormat(CF_RTF);

CF_BITMAP

Randy More's article (http://www.codeguru.com/clipboard/bitmap_to_clipboard.shtml) 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.

Table 4 - Delayed Rendering a CBitmap

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);
	}

CF_ENHMETAFILE

Randy More's article (http://www.codeguru.com/clipboard/emf_to_clipboard.shtml) 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.

Table 5 - Delayed Rendering a Metafile

	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);
	}

Clipboard Preference

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.

Table 6 - MS-Office Clipboard Preferences

Format

MS-Word 97

(To a blank page)

MS-Excel 97

(To a blank workbook)

MS-PowerPoint 97

(To a blank slide)

Drag/Drop

Cut/Copy/Paste

Drag/Drop

Cut/Copy/Paste

Drag/Drop

Cut/Copy/Paste

CF_BITMAP

3

4

-

4

-

2

CF_ENHMETAFILE

-

3

-

3

-

1

CF_RTF

1

1

-

-

1

3

CF_TEXT

2

2

1

1

2

4

Csv

-

-

2

2

-

-



Comments

  • the with greatest satisfaction guerdon you can go for the clarisonic outstanding

    Posted by iouwanzi on 06/06/2013 08:26pm

    [url=http://www.miaclarisonicaustralia.org/]clarisonic mia[/url] Ghd IV styler lisseur où acheter défrisants ghd aux questions économiques? Seulement il suffit de suivre le lien ci-dessous et vous devriez maintenant commencer à frapper votre corps!Sa solution de traitement en profondeur de traitement est certainement pourrait combiner quelque chose d’autre dans l’eau pendant une gammes de prix ghd lisseur. Pouce romanciers possibilité réelle ne pense pas que le bureau à domicile types package peut sembler la route vers le site world-wide-web pour la marque d’avoir toutes les opportunités uniques trouvés dans le site Web de kilométrage publicité en général. Ghd lisseur donner 5 eux-mêmes, vous pouvez habiller la manière Quelqu’un veut jouer ce que viennent généralement environs Pour ceux qui connaissent les poils indésirables, pour vous inscrire à votre communauté cheveux doivent être prêts à vous aider à obtenir le genre de perte de cheveux inattendu est habituellement causée par une maladie auto-immune grave, et aussi de temps en temps, une sorte négatif de réaction à des médicaments sûrs que vous avez travaillé, effectuez l’heure suivante plupart d’entre nous sur le fait que sans douleur que vous bénéficiez que 100% de tous les médias vidéo gratuit en ligne principalement parce que la plupart d’entre nous ne veulent pas quelqu’un qui cherche à d’innombrables heures à consacrer à le faire! [url=http://www.miaclarisonicaustralia.org/]clarisonic mia 2[/url] ghd pas cher peut être une marque japonaise de qui vend le fer à lisser en céramique et même des produits qui comprennent un sèche-cheveux, bonne prise en charge ainsi que des brosses. Que les modèles de plaque de céramique habituellement sont associés à premium et en particulier le lisseur chauffe en quelques minutes. At taper l’ultramoderne sera même petit bip qui vous avertit qu’il peut être tous ensemble.Superb confortable ! [url=http://www.australiaclarisonic.com/]clarisonic brush[/url] Notre coiffeur étranger encouragés plus tôt ghd Gold styler à mon avis, ainsi que maintenant nos U. s. salon de coiffure en outre leur préféré dans mon expérience – car il est ce que vos applications amant dans le salon, ainsi qu’à la maison (la dame s’avère en outre faire un copain, donc mon partenaire et j’ai confiance dans la jeune fille!). Votre nom de marque est en fait le meilleur et même fera un cheveux sentiment fantastique.Réveillé par le glamour unique dans les années folles, cutting edge styler généralement la méthode pour obtenir l’attraction en ajoutant une touche de paillettes. Tous l’écarlate s’engage dans seulement deux cas Craft Deco design et le style que vous pourriez choisir.

    Reply
  • Nike Zephyr Max 1 FB publicity, have a piquant color character, the chic shoes

    Posted by Geozyoceada on 04/23/2013 09:54am

    In the summer in a glass inside the imperturbable sprite seems to be a good fitting, but if the sprite "feet"? Longing also disclose you a set off, take a invigorating! This summer, Nike and Sprite [url=http://northernroofing.co.uk/roofins.cfm]nike free[/url] and his sneakers to a blend of classic snow spread of non-professional, unsullied and downcast color system in the time-honoured Nike Superciliousness Max 1 shoes let it be known a like a breath of fresh air presumptuous scent.[url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] Summer is the duration to pick a purified shoe, shoes should be a good choice. Qualifying series Nike Air Max HomeTurf borough recently lastly comes up, this series in the immortal Air Max shoes to London, Paris and Milan the three paid glorification to the iconic city of Europe, combined with the characteristics of the three cities, Feeling Max 1 HYP,Allied Max 90 HYP,Air Max 1 and shoes such as Style Max 95, combined [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] with the Hyperfuse, as marvellously as a variety of materials, such as suede, Whether you crave going or retro-everything.

    Reply
  • Nike Air Max+instagram, at one's desire you confine the color to bear up on your feet!

    Posted by madytreathy on 04/22/2013 08:18am

    Recognize in 2008, if not earlier, when Nike launched on of the separated shoe color projects, the watchword "Whiz Your Colours", "Nike PhotoiD" scheme, [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] return has not been as fervent as expected. Have in mind, 2008 Canon IXUS 80 IS Digital file card arcade but purely 8 million pixels, Nokia, the mobile phone superstore is the exclusively regulation, NikeiD was boost to color in the photos as a essence someone is concerned sneakers levy color, although interesting, but does bother some. Instagram which sort this thing hold up to ridicule and fundamental, Nike PHOTOiD homeopathic upgrade customization services, recently [url=http://northernroofing.co.uk/roofins.cfm]nike free uk[/url] released a unique plan. That such iD can you realize pictures as instagram account shoe color, temporarily make available Nike Mood Max shoes and Nike Air Max 1, Nike Feeling Max 90 953 options. Interested in children's shoes, you [url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] can without exception conform with each other's legitimate website photoid.Nike.com, in besides to skim through other people's creative work, or you can make an effort to upload your own instagram photo, build your own Nike Feeling Max.

    Reply
  • Problem with CClipExamView::OnEditCopy()

    Posted by Legacy on 11/06/2002 12:00am

    Originally posted by: ali

    Hi,
    In your CClipExamView::OnEditCopy(), you create an instance of CMyOleDataSource which is automatically deallocated after the function exits. This causes a memory exception when the target tries to retrieve the data by calling (indirectly) OnRenderGlobalData(). (At least it does in my test application).

    Any Ideas?

    Thanks,
    AG

    Reply
  • ClipBoard- How to copy or paste the custem format

    Posted by Legacy on 12/31/2001 12:00am

    Originally posted by: Chandru

    This is MFC application
    
    I declared UINT ctFormat; as member function

    i placed the following code in constructer of view class

    ctFormat = UINT ctFormat= RegisterClipboardFormat("JBPL");

    using wizered i written two methods...
    1. OnCopy()
    2. OnPaste()


    //OnCopy Menu item
    void CGuiClipDlg::OnCopy()
    {



    HGLOBAL ctMolecule;
    if(OpenClipboard())
    {
    EmptyClipboard();
    CMetaFileDC *pMetaDC=new CMetaFileDC();
    CRect rect;
    GetClientRect(&rect);
    pMetaDC->CreateEnhanced(GetDC(),NULL,NULL,"IMAG");
    draw(pMetaDC);
    HENHMETAFILE hMF=pMetaDC->CloseEnhanced();

    //another own format
    char mytext[]="Happy New Year";
    int bufferSize = strlen (mytext)+1;
    ctMolecule=::GlobalAlloc(GMEM_MOVEABLE |GMEM_DDESHARE,bufferSize);
    LPSTR memory = (LPSTR)::GlobalLock(ctMolecule);
    memcpy(memory,mytext,bufferSize);
    SetClipboardData(CF_ENHMETAFILE,hMF);
    SetClipboardData(ctFormat,ctMolecule);
    ::GlobalUnlock(ctMolecule);

    CloseClipboard();
    delete pMetaDC;
    }

    //OnPaste Menu item
    void CGuiClipDlg::OnButtonPaste()
    {


    if(OpenClipboard ())
    {
    HENHMETAFILE handle=(HENHMETAFILE)GetClipboardData(CF_ENHMETAFILE);
    CClientDC dc(this);
    CRect rect(0,0,100,100);
    dc.PlayMetaFile(handle,rect);

    //This is for own formate
    HGLOBAL ctMolecule;
    ctMolecule = GetClipboardData(ctFormat);
    char szStr[20];
    char ch[10]="\n";
    strncpy(szStr,(char*)ctMolecule,20);
    szStr[20]='\0';
    CDC* cdc=this->GetDC();
    cdc->TextOut(0,100,szStr);
    TRACE("%s\n",szStr);

    GlobalUnlock( ctMolecule);
    CloseClipboard();

    }


    in draw()method i am doing ellipse

    my problem is when i am making copy to MS WORD it only pastes circle, but not the own formate i.e.Happy New Year

    if i am looking in vc++ DataObjectViewer tool,own format JBPL is
    if i am viewing in vc++ DataObject viewer tool,i can able to see the registerd own format i.e "JBPL"..

    but why cant it paste to MS WORD

    Please help in this..

    actualy i need copy and paste own graphics format..

    Reply
  • Please Help:Problem with Delayed Rendering

    Posted by Legacy on 09/19/2000 12:00am

    Originally posted by: Sudhir Kelappan

    I tried using this sample code for delayed rendering. I discovered that COleDataSource::OnRenderData () is called multiple times. First whenever there is a right click (i.e. whenever a context menu is about to be activated) and also when the paste option is invoked from the ctxt. menu.

    It is called multiple times in between before the context menu appears

    I am using CF_HDROP format to transfer file names to explorer.

    I will appreciate any help on this

    Thanx
    Sudhir

    • Delayed Rendering - stopping multiple calls

      Posted by Gav_ on 10/23/2006 08:31am

      The solution is to pass a COleDropSource instance to your "DoDragDrop" call like below. You will need to derive your own class COleDropSource class.
      
      // Change your DoDragDrop call to this:
      	CMyDropSource oDropSource(pDataSource);
      	pDataSource->DoDragDrop(DROPEFFECT_COPY|DROPEFFECT_MOVE|DROPEFFECT_LINK, 0, &oDropSource);
      
      
      // Derive your own COleDropSource class like this:
      	class CMyDropSource : public COleDropSource
      	{
      	public:
      		CMyDropSource(CMyOLEDragDrop *pDataSourceParam);
      		virtual ~CMyDropSource();
      		virtual SCODE QueryContinueDrag(BOOL bEscapePressed, DWORD dwKeyState);
      	private:
      		CMyOLEDragDrop *pDataSource;
      	};
      
      
      	//CMyDropSource class
      
      	CMyDropSource::CMyDropSource(CMyOLEDragDrop *pDataSourceParam)
      	: COleDropSource()
      	, pDataSource(pDataSourceParam)
      	{}
      
      	CMyDropSource::~CMyDropSource()
      	{
      	}
      
      	SCODE CMyDropSource::QueryContinueDrag(BOOL bEscapePressed, DWORD dwKeyState)
      	{
      		SCODE sCode = COleDropSource::QueryContinueDrag(bEscapePressed, dwKeyState);
      		if ( sCode == DRAGDROP_S_DROP ) {
      			if ( pDataSource != NULL )
      				pDataSource->EndDrop();
      		}
      		return sCode;
      	}
      
      
      // And add a function and a bool "m_bDropped" to your COleDataSource class, set the m_bDropped to false in your constructor. It is set to true by the COleDropSource function call to EndDrop
      
      	bool m_bDropped;
      	void EndDrop() {m_bDropped = true;}
      
      
      // Then at the start of your OnRenderGlobalData function add a check on the m_bDropped member varable, if it isn't true then just return.
      
      	if( !m_bDropped )
      		return FALSE;

      Reply
    Reply
  • Is it possible to use Delayed Rendering when the source is Windows Explorer

    Posted by Legacy on 08/08/2000 12:00am

    Originally posted by: Dheeraj Sood

    Hi,

    I have a peculiar problem. My application need to query Windows Explorer for the names of files which are currently selected (but not copied to the clipboard) in WE.

    I need to invoke this functionality when WE (with one or more files selected) gets de activated and my application gets activated.

    I am able to query the filenames once i have copied the selection to the clipboard but not otherwise.

    Is it possible for me to use delayed rendering in my application and instruct Windows Explorer to copy the selected data to the clipboard ?? I know once the selected files are copied to the clipboard I am able to retieve the filenames but not otherwise.

    I would sincerely appreciate any help that i can get on this !!!

    thanks

    Dheeraj

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

  • As more and more organizations migrate to the cloud, many are faced with hidden costs emerging from unexpected places. Two non-obvious and non-trivial factors can drive up costs. First are separate charges for everything from server memory to intrusion detection. Second are the high personnel costs for early-generation, manually operated clouds. These costs can rack up quickly, creating total cost of ownership (TCO) surprises. Keeping TCO low in the cloud is essentially a matter of management strategy. IT …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds