|
#include <vector>
using namespace std;
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall WMDropFiles(TWMDropFiles &Msg);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_DROPFILES, TWMDropFiles, WMDropFiles);
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
void __fastcall TForm1::FormCreate(TObject *Sender)
{
DragAcceptFiles(Handle, true);
}
void __fastcall TForm1::WMDropFiles(TWMDropFiles &message)
{
char fullPath[MAX_PATH];
UINT fileCount = DragQueryFile((HDROP)message.Drop,0xffffffff,NULL,0);
for(UINT i=0 ;i<fileCount ;i++)
{
DragQueryFile((HDROP)message.Drop,i,fullPath,MAX_PATH);
// Memo1->Lines->Add(fullPath);
}
DragFinish((HDROP)message.Drop);
}
//---------------------------------------------------------------------------
위 코드와 같이 BEGIN_MESSAGE_MAP 을 이용하면 탐색기에서 드래그 하고 놓는 순간 이벤트가 감지 되어야 하는데
WMDropFiles함수에 디버깅을 위하여 브레이크를 걸어도 함수 호출 자체가 되지 않습니다...
|