Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
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);
	//dc.BitBlt(0,0,100,100,&dcMem,0,0,SRCCOPY);
	mm_imglist->DrawIndirect (&dcMem, 0/*index*/, CPoint (0, 0), CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
	dc.BitBlt(0,0,100,100,&dcMem,0,0,SRCCOPY);
	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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900