我成功实现你的要求,现将所有源码附上,记得加分哟!!!!!
将头文件与实现文件加入到你的工程中,在对话框类中用下面这个类定义你的按钮,在对话框OnInitDialog中添加该按钮对象的EnableDragFile( TRUE )即可实现按钮拖放文件,10个按钮就生成10个对象呗!我在演示中当拖动到按钮时显示拖动文件的名字,如果是ShortCut文件,你可以自己展开。好了,下面是代码,Enjoy it!//头文件
// DragButton.h : header file
#if !defined(AFX_DRAGBUTTON_H__6DAC8BB0_7EE6_11D5_A513_EF78E77DDE1C__INCLUDED_)
#define AFX_DRAGBUTTON_H__6DAC8BB0_7EE6_11D5_A513_EF78E77DDE1C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//
//作者:沈阳王加宝
//创建:2001.07.22-21:39
/////////////////////////////////////////////////////////////////////////////
// CDragButton windowclass CDragButton : public CButton
{
// Construction
public:
CDragButton();// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDragButton)
//}}AFX_VIRTUAL// Implementation
public:
virtual void EnableDragFile(BOOL bEnable);
virtual ~CDragButton(); // Generated message map functions
protected:
//{{AFX_MSG(CDragButton)
//}}AFX_MSG
int OnDropFiles(WPARAM wParam,LPARAM lParam); DECLARE_MESSAGE_MAP()
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_DRAGBUTTON_H__6DAC8BB0_7EE6_11D5_A513_EF78E77DDE1C__INCLUDED_)//实现文件
// DragButton.cpp : implementation file
//#include "stdafx.h"
#include "DragButton.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CDragButtonCDragButton::CDragButton()
{
}CDragButton::~CDragButton()
{
}
BEGIN_MESSAGE_MAP(CDragButton, CButton)
//{{AFX_MSG_MAP(CDragButton)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_DROPFILES,OnDropFiles)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CDragButton message handlersint CDragButton::OnDropFiles(WPARAM wParam,LPARAM lParam)
{
SetActiveWindow(); CString s("拖动来文件有:");//
HDROP hDropInfo = (HDROP)wParam;
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0); for (UINT iFile = 0; iFile < nFiles; iFile++)
{
TCHAR szFileName[_MAX_PATH];
::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);

//TODO:加入你的处理内容
s += szFileName;
s += " ; ";
}

::DragFinish(hDropInfo);

AfxMessageBox( s );// return 0;
}//允许文件拖放
void CDragButton::EnableDragFile(BOOL bEnable)
{
DragAcceptFiles( bEnable );
}