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

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


Need help with drag and drop

John and Cecilia -- jandce@iglobal.net
Tuesday, January 07, 1997

Environment: MSVC 4.0/Win95

I have an application that uses a list view to display files on a network
drive.
I would like to be able to drag from the list a file or selection of files
to a folder or drive on my computer.

I have over-ridden the OnBegindrag() of my view as follows:

void View::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	DragFile* drag = new DragFile( CF_TEXT );   //have also tried registered
value
	DROPEFFECT drop = drag->DoDragDrop( DROPEFFECT_COPY|DROPEFFECT_MOVE );
	if( drop == DROPEFFECT_COPY )
		AfxMessageBox( "Drop copy" );
	if( drop == DROPEFFECT_MOVE )
		AfxMessageBox( "Drop move" );
	delete drag;
	*pResult = 0;
}

DragFile is a class derived from COleDataSource. The constructor calls
DelayRenderFileData for me. I have passed along CF_TEXT and the CF_*
returned from my RegisterFormat() call with the same results.

I have also over-ridden the OnRenderFileData() function, in the hopes that
I will be able to retreive the file from the remote location and save it to
the dropped location.

Problem: When I drag to a folder or drive on my computer, I get the circle
with a bar (no drop allowed) except for when I am over the trash container.
The HEIRSVR sample uses COleServerItem, but it requires that the document
be of a type COleDocument. My document is not and does not really need to
be.

Any ideas on what I could be missing or where else I should look would be
greatly appreciated.
-- 
John Boehme
jandce@iglobal.net
http://www.iglobal.net/pub/JohnAndCe/webmap.htm
http://www.iglobal.net/pub/JohnAndCe/ftpcontrol.htm





Tim Robinson -- timtroyr@ionet.net
Monday, January 13, 1997

At 21:46 1/7/97 -0600, you wrote:
>Environment: MSVC 4.0/Win95
>
>I have an application that uses a list view to display files on a network
>drive.
>I would like to be able to drag from the list a file or selection of files
>to a folder or drive on my computer.
>
>I have over-ridden the OnBegindrag() of my view as follows:
 
[Code snipped... it's probably OK]

>Problem: When I drag to a folder or drive on my computer, I get the circle
>with a bar (no drop allowed) except for when I am over the trash container.
>The HEIRSVR sample uses COleServerItem, but it requires that the document
>be of a type COleDocument. My document is not and does not really need to
>be.
>
>Any ideas on what I could be missing or where else I should look would be
>greatly appreciated.

My guess is that when you started this project, you didn't tell the Wizard
to include OLE support... which the d&d depends on.  (hehe... guess how I
knew this.)  Go to your App::InitInstance() and put in a call to
AfxOleInit() with appropriate error checking.  It should start to work.

| Tim Robinson, Esquire          | Liberty  means responsibility. |
| timtroyr@ionet.net             | That is why most men dread it. |
| http://www.ionet.net/~timtroyr |            George Bernard Shaw |




Irfan Shariff -- irfan_s@london.altris.com
Wednesday, January 15, 1997

[Mini-digest: 3 responses]

Hello, 

I've just joined this list so I don't have access to your original message. But its
sounds like a problem I have had. I solved it by using the CF_HDROP style. 
This structure is documented by J.Richter in MSDN. Just look up 
"CF_HDROP" as the search query. 

In his article he has written functions that add files into the HDROP structure.
Basically if you fill this structure any application that support DragAcceptFiles
will allow files to be dropped on to it. Such applications include the Windows 
Explorer and the W95 shell.

As Tim points out you will need to do the AfxOleInit() in InitInstance. I don't
know if you have implemented OLE drag and drop, but you need to if you 
are to use the above.

Hope this helps.

Irfan.

-----From: Shaju Mathew 

Did you also make a call to DragAcceptFiles() in the init routine
of your client window??
> 
> At 21:46 1/7/97 -0600, you wrote:
> >Environment: MSVC 4.0/Win95
> >
> >I have an application that uses a list view to display files on a network
> >drive.
> >I would like to be able to drag from the list a file or selection of files
> >to a folder or drive on my computer.
> >
> >I have over-ridden the OnBegindrag() of my view as follows:
>  
> [Code snipped... it's probably OK]
> 
> >Problem: When I drag to a folder or drive on my computer, I get the circle
> >with a bar (no drop allowed) except for when I am over the trash container.
> >The HEIRSVR sample uses COleServerItem, but it requires that the document
> >be of a type COleDocument. My document is not and does not really need to
> >be.
> >
> >Any ideas on what I could be missing or where else I should look would be
> >greatly appreciated.
> 
> My guess is that when you started this project, you didn't tell the Wizard
> to include OLE support... which the d&d depends on.  (hehe... guess how I
> knew this.)  Go to your App::InitInstance() and put in a call to
> AfxOleInit() with appropriate error checking.  It should start to work.
> 
> | Tim Robinson, Esquire          | Liberty  means responsibility. |
> | timtroyr@ionet.net             | That is why most men dread it. |
> | http://www.ionet.net/~timtroyr |            George Bernard Shaw |
> 
> 


--
***********************************************************************
                              .---.         .---.
Shaju Mathew                 /" "  \  WWW  /  " "\    Off:(916)785-9018 
Performance Technology Lab  / / ""  \(*|*)/  "" \ \ 
WCSO Group R & D           //////   '. V .`   \\\\\\ Home:(916)722-4576
Hewlett-Packard Company   //// / // : """ : \\ \ \\\\
8000, Foothills Blvd     // /   /  /`.""" '\  \   \ \\Fax:(916)785-1264
MS 5723, Roseville      //          //.".\\          \\
CA 95747-5723        	     -------UU---UU-------
                                   '//|||\\`        Shaju_Mathew@hp.com
***********************************************************************
-----From: "John Boehme" 

Thanks for the reply. However, I am calling AfxOleInit() in my
InitInstance.
Another reply said to use CF_HDROP. I have not got it working yet but I am
now at least making some progress.

John Boehme
http://www.iglobal.net/pub/jandce/webmap.htm
http://www.iglobal.net/pub/jandce/ftpcontrol.htm

----------
> From: Tim Robinson 
> To: mfc-l@netcom.com
> Subject: Re: Need help with drag and drop
> Date: Monday, January 13, 1997 11:21 PM
>
> My guess is that when you started this project, you didn't tell the
Wizard
> to include OLE support... which the d&d depends on.  (hehe... guess how I
> knew this.)  Go to your App::InitInstance() and put in a call to
> AfxOleInit() with appropriate error checking.  It should start to work.
> 
> | Tim Robinson, Esquire          | Liberty  means responsibility. |
> | timtroyr@ionet.net             | That is why most men dread it. |
> | http://www.ionet.net/~timtroyr |            George Bernard Shaw |



Kostya Sebov -- sebov@is.kiev.ua
Friday, January 17, 1997

In the mfc-l Irfan Shariff  wrote:
>   Hello,
>
>   I've just joined this list so I don't have access to your original message. But its
>   sounds like a problem I have had. I solved it by using the CF_HDROP style.
>   This structure is documented by J.Richter in MSDN. Just look up
>   "CF_HDROP" as the search query.
>
>   In his article he has written functions that add files into the HDROP structure.
>   Basically if you fill this structure any application that support DragAcceptFiles
>   will allow files to be dropped on to it. Such applications include the Windows
>   Explorer and the W95 shell.
>

Just to warn you... Someone in my company has discovered that the CF_HDROP-related
structures are different in Win95, NT 3.51 and NT 4.0 (the same for the two of them,
different for the other -- don't remember which one).

The original message follows:
>   >Environment: MSVC 4.0/Win95
>   >
>   >I have an application that uses a list view to display files on a network
>   >drive.
>   >I would like to be able to drag from the list a file or selection of files
>   >to a folder or drive on my computer.
>   >
>   >I have over-ridden the OnBegindrag() of my view as follows:
>
>    [Code snipped... it's probably OK]
>
>   >Problem: When I drag to a folder or drive on my computer, I get the circle
>   >with a bar (no drop allowed) except for when I am over the trash container.
>   >The HEIRSVR sample uses COleServerItem, but it requires that the document
>   >be of a type COleDocument. My document is not and does not really need to
>   >be.
>   >
>   >Any ideas on what I could be missing or where else I should look would be
>   >greatly appreciated.
>
--- 
Kostya Sebov. 
----------------------------------------------------------------------------
Tel: (38 044) 266-6387 | Fax: (38 044) 266-6195 | E-mail: sebov@is.kiev.ua



Dulepov Dmitry -- dima@ssm6000.samsung.ru
Monday, January 20, 1997

[Mini-digest: 2 responses]

        [Mailer: "Groupware E-Mail". Version 1.02.055]

>        [From: Kostya Sebov
>
>Someone in my company has discovered that the CF_HDROP-related
>structures are different in Win95, NT 3.51 and NT 4.0 (the same for the two of them,
>different for the other -- don't remember which one).
>

Note: Windows developers team does not recommend to create commercial application for Windows NT 3.51 with new shell. It was a prerelease and it does not work well in many cases.


Dmitry A. Dulepov
Samsung Electronics Co., Ltd.
Russian Research Center
Phone: +7 (095) 213-9207
Fax: +7 (095) 213-9196
E-mail: dima@src.samsung.ru
====================================

-----From: Kostya Sebov 

>           [Mailer: "Groupware E-Mail". Version 1.02.055]
>
>   >        [From: Kostya Sebov
>   >
>   >Someone in my company has discovered that the CF_HDROP-related
>   >structures are different in Win95, NT 3.51 and NT 4.0 (the same for the two of them,
>   >different for the other -- don't remember which one).
>   >
>
>   Note: Windows developers team does not recommend to create commercial application for Windows NT 3.51 with new shell. It was a prerelease and it does not work well in many cases.
>
>
>   Dmitry A. Dulepov
>
I made some invesigations on my own and found that the warning I issued does
not relate to CF_DROP but the structure related to HDROP (a handle sent in wParam
of WM_DROPFILES message). This UNDOCUMENTED structure is described by Jeffrey Richter
in the MSJ #2 1994.

I appologize for the confusion, which may have resulted from my posting.

--- 
Kostya Sebov. 
----------------------------------------------------------------------------
Tel: (38 044) 266-6387 | Fax: (38 044) 266-6195 | E-mail: sebov@is.kiev.ua




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