15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Drag and Drop File-Server

Wolfgang Loch -- Wolfgang.Loch@RZ.TU-Ilmenau.DE
Thursday, May 30, 1996

Environment Visual C++2.0 WinNT(3.51)

I want to make a Drag and Drop File Server (like then Filemanager).

I've got a Listbox in a Dialog-based application that contains
filenames. I want the user to be able to drag these files to another app
or to copy them to the Filemanager.
So far I found out that a should use CDataSource::DoDragDrop. But I
didn't get it to work. Does anyone have a hint and/or some sample code?

thanks,
	Wolfgang



Thomas Drolshagen -- drolshagen@deos.ch
Monday, June 03, 1996

Hi Wolfgang
For only implementing file drag and drop (no OLE drag and drop) there's a
sample on the Microsoft Development Library calle DRAGDROP.
If you need OLE drag and drop check:
 - Internet (anonymous FTP)
      ftp ftp.microsoft.com
      Change to the SOFTLIB\MSLFILES directory
      Get LSTDRG.EXE
HTH
Thomas Drolshagen

>----------
>From: 	Wolfgang Loch[SMTP:Wolfgang.Loch@RZ.TU-Ilmenau.DE]
>Sent: 	Donnerstag, 30. Mai 1996 07:48
>To: 	mfc-l@netcom.com
>Subject: 	Drag and Drop File-Server
>
>Environment Visual C++2.0 WinNT(3.51)
>
>I want to make a Drag and Drop File Server (like then Filemanager).
>
>I've got a Listbox in a Dialog-based application that contains
>filenames. I want the user to be able to drag these files to another app
>or to copy them to the Filemanager.
>So far I found out that a should use CDataSource::DoDragDrop. But I
>didn't get it to work. Does anyone have a hint and/or some sample code?
>
>thanks,
>	Wolfgang
>



Brian Jones -- BrianJ@ats-nt.apptechsys.com
Thursday, June 27, 1996


Here is a simple class that serializes a list of files for a drag/drop   
server:

IMPLEMENT_SERIAL(CDragFiles, CObject, 1);


CDragFiles::CDragFiles(CStringList* plistFiles)
{
 m_plistFiles = plistFiles;
}

CDragFiles::~CDragFiles()
{
}

void CDragFiles::Serialize( CArchive& archive )
{
 DROPFILES df;
 POSITION pos;
 CString strFile = "";
    // now do the stuff for our specific class
 if( archive.IsStoring() )
 {
  df.pFiles = (DWORD)(sizeof(DROPFILES));
  df.pt.x = 0;
  df.pt.y = 0;
  df.fNC = 0;
  df.fWide = 0;
  archive.Write(&df, sizeof(DROPFILES));

  if((m_plistFiles) && (!m_plistFiles->IsEmpty()))
  {
   pos = m_plistFiles->GetHeadPosition();
   while(pos)
   {
    strFile = m_plistFiles->GetNext(pos);
    archive.Write(strFile.GetBuffer(strFile.GetLength()),strFile.GetLength  
());
    archive.Write("\0",1);
   }
   archive << (int)0;
  }
 }
}


This can be implemented with the following code:

Given a CStringList* plistFiles filled with the list of files to be   
dragged:

  CSharedFile fileList;
  CString strData = "";
  CArchive ar(&fileList,CArchive::store);
  if(!plistFiles->IsEmpty())
  {
   CDragFiles df(plistFiles);
   df.Serialize(ar);
   ar.Close();

   plistFiles->RemoveAll();
   pDataSource->CacheGlobalData(CF_HDROP,fileList.Detach());
  }


Hope this helps some.

Brian Jones
BrianJ@apptechsys.com
(360)478-2710 ext 3209

//////////////////////////////////////////////////////////////////////////  
//////////////////////////////////////////////
In response to:
//////////////////////////////////////////////////////////////////////////  

Environment Visual C++2.0 WinNT(3.51)

I want to make a Drag and Drop File Server (like then Filemanager).

I've got a Listbox in a Dialog-based application that contains
filenames. I want the user to be able to drag these files to another app
or to copy them to the Filemanager.
So far I found out that a should use CDataSource::DoDragDrop. But I
didn't get it to work. Does anyone have a hint and/or some sample code?

thanks,
        Wolfgang





| Вернуться в корень Архива |