Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0 C++ MFC
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 14-Apr-10 22:37pm

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

  Print Answers RSS
0 OriginalGriff 390
1 Jochen Arndt 165
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 15 Apr 2010
Copyright © CodeProject, 1999-2014
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