|
OLE Drag&Drop 에 관해서 알아보셔야 할 것 같네요.
I haven't tried it in Internet Explorer yet, but you may have to do this the
long and hard OLE way. I'm not sure but IExplorer may intercept the
WM_DROPFILES message and not send the message to your window. With OLE drag
and drop, you register your window with the Windows OS, and your code is
called via IDropTarget interface. This means your window in your control
that you want to accept the files should implement the IDropTarget interface
(see Win32 OLE help for OLE Drag and Drop). Implement all the necessary
methods of IDropTarget (there are 4, I believe). Then at the creation of
your control you would register the hwnd of the control's window as the drop
target. Beware, this is all Win Api code because CBuilder has no way of
doing OLE drag and drop, at least not that I am aware of.
// At the beginning of your program somewhere...
void __fastcall TMainForm::FormCreate(TObject *Sender)
{
OleInitialize(NULL);
m_TreeDropTarget = new TPMTreeDropTargetImpl(TreeView1);
HRESULT hRes = RegisterDragDrop(Handle, (IDropTarget *)
m_TreeDropTarget);
....
....
}
// Below is an example of a code snippet that you could use to extract the
data from the IDataObject
// I implemented it in "DragEnter" because I wanted to know what the
specific files were. You might just
// need to implement it in the "Drop" method.
HRESULT STDMETHODCALLTYPE TDropTargetImpl::DragEnter(
/* [unique][in] */ IDataObject __RPC_FAR *pDataObject,
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ DWORD __RPC_FAR *pdwEffect)
{
FORMATETC format;
memset(&format, 0, sizeof(FORMATETC));
// Go through each data format and see if it is one that we know how
to handle
pDataObject->BeginEnumFormats();
while(pDataObject->GetNextFormat(&format))
{
if (format.cfFormat == CF_HDROP) // explorer file drop
{
STGMEDIUM medium;
pDataObject->GetData(format.cfFormat, &medium);
// The following assertion may not work in CBuilder, it is an MFC
macro
ASSERT(medium.tymed == TYMED_HGLOBAL); // if it is an HDROP, then it
should be an HGLOBAL
// Lock global memory while we access it
byte* pmem = (byte*) GlobalLock (medium.hGlobal);
// The HGLOBAL is actually a DROPFILES structure
DROPFILES * pDF = (DROPFILES *) pmem;
// Get the pointer to where the list of files is stored.
BYTE * pFilesInMem = pmem + pDF->pFiles;
// The list of files is actually a string list delimited by NULL
and terminated by double NULL
WCHAR * pFiles = (WCHAR *) pFilesInMem;
GlobalUnlock (medium.hGlobal); // done with the global data
}
}
return S_OK;
}
Julien 님이 쓰신 글 :
: ActiveX를 만들어서 파일드래그를 하도록 설정했습니다.
: 이걸 비주얼스튜디오에 있는 ActiveX Control Test Container에서 테스트하면서
: 작업을 하다가 어느 정도 진행된 뒤에 Cab으로 압축하여 웹서버에 실었습니다.
: 테스트 중에는 탐색기에서 파일을 끌어와 놓으면 잘 되었는데 웹브라우저에 놓이니까
: 웹브라우저가 컨트롤보다 먼저 드래그앤드랍 이벤트를 받아서 처리해버리는 군요
: 웹브라우저의 드래그앤드랍 기능을 정지시켜야 할 것 같은데 방법이 없을까요?
|