Click here to Skip to main content
13,045,285 members (55,629 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear all;

I want to get the icon of the file or shortcut that is dropped and

draded into the window. How could I do this?

Now, I try to do this by modify the program of

How to Implement Drag and Drop Between Your Program and Explorer[^]

I want to extract the icon of the Imagelist structure

and modify the code as below:

void CMultiFilerDlg::OnPaint()
	CPaintDC dc(this); // device context for painting
	//CClientDC   dc(NULL);
	CImageList    *mm_imglist;
	mm_imglist = c_FileList.GetImageList(LVSIL_SMALL);
	IMAGEINFO imageinfo;
	mm_imglist->GetImageInfo(0, &imageinfo);
	int x = mm_imglist->GetImageCount();
	CDC dcMem;
	dcMem.CreateCompatibleDC (&dc); // dc is a CDC you already have from one of your app windows
	CRect rect (imageinfo.rcImage);
	CBitmap bmp;
	bmp.CreateCompatibleBitmap (&dc, rect.Width (), rect.Height ());
	CBitmap* pBmpOld = dcMem.SelectObject (&bmp);
	mm_imglist->DrawIndirect (&dcMem, 0/*index*/, CPoint (0, 0), CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
	dcMem.SelectObject (pBmpOld);
	// TODO: Add your message handler code here
	// Do not call CDialog::OnPaint() for painting messages*/

But what I extract is not the icon I put into the window, and I find the mm_imglist is not change after I put the file.

Please give a help and thanks all.
Posted 14-Apr-10 21:37pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 15 Apr 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100