SAMPLE: MFCDRAG Implements Drag&Drop Between CListCtrl & CTree

Last reviewed: July 2, 1997
Article ID: Q148738
The information in this article applies to:
  • The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Edition, versions 4.0, 4.1, 5.0

SUMMARY

MFCDRAG shows how to implement drag and drop between a CListCtrl and CTreeCtrl. The program creates a splitter window containing four panes. Two panes contain CListCtrls and the other two contain CTreeCtrls. You can drag an item from any window to another. For example, dragging can occur between the following panes:

   CListCtrl to CTreeCtrl
   CListCtrl to CListCtrl
   CTreeCtrl to CListCtrl
   CTreeCtrl to CTreeCtrl

Code marked with the comment "Added 7/29/96" was added to support a change in the CreateDragImage function in MFC 4.2. The CImageList pointer returned from CreateDragImage must now be explicitly deleted. If you are using a version of MFC prior to 4.2, please comment this code out.

The following file is available for download from the Microsoft Software Library:

 ~ Mfcdrag.exe (size: 36508 bytes) 

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q119591
   TITLE     : How to Obtain Microsoft Support Files from Online Services

NOTE: Use the -d option when running MFCDRAG.EXE to decompress the file and recreate the proper directory structure.


Additional query words: drag drop
Keywords : CListCtrl CTreeCtrl kbfile kbprg kbsample MfcUI
Technology : kbMfc
Version : 4.0 4.1 5.0
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.