C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[20307] Re:웹브라우저 내의 ActiveX에서 파일 드래그앤드랍 문제
유영인.Chris [cuperido] 1986 읽음    2002-07-23 14:07
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으로 압축하여 웹서버에 실었습니다.
: 테스트 중에는 탐색기에서 파일을 끌어와 놓으면 잘 되었는데 웹브라우저에 놓이니까
: 웹브라우저가 컨트롤보다 먼저 드래그앤드랍 이벤트를 받아서 처리해버리는 군요
: 웹브라우저의 드래그앤드랍 기능을 정지시켜야 할 것 같은데 방법이 없을까요?

+ -

관련 글 리스트
20227 웹브라우저 내의 ActiveX에서 파일 드래그앤드랍 문제 Julien 1302 2002/07/19
20307     Re:웹브라우저 내의 ActiveX에서 파일 드래그앤드랍 문제 유영인.Chris 1986 2002/07/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.