The DnDZoom.exe sample demonstrates how to implement a drag-and-drop and zoom operation in the ATL framework in Visual C++

This article was previously published under Q247072
This article has been archived. It is offered "as is" and will no longer be updated.
Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code. Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.
SUMMARY
DnDZoom.exe is a sample that demonstrates how to implement a drag-and-drop and zoom operation in the ATL framework. Implementing only a drag-and-drop operation or only zooming capabilities in an ATL control is a straightforward process. However, when you have to implement both, a design decision needs to be made. Here are some of the available design options:
  • Provide a dedicated area in the control for initiating drag-and-drop operations.
  • Use CTRL+DRAG to initiate a drag-and-drop operation (while a regular drag would still perform the zoom operation).
  • Implement a smart drag-and-drop operation that determines, based on the drop target, whether a zoom or a drag-and-drop operation is desired.
The first two solutions have obvious shortcomings. DnDZoom.exe implements the third solution: when the mouse is released outside of the control a drag-and-drop operation is performed. However, when the mouse is released inside the control, a zoom operation is completed.
MORE INFORMATION
The following files are available for download from the Microsoft Download Center:

Visual C++ 6.0

The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Visual C++ .NET

The following file is available for download from the Microsoft Download Center:
Release Date: June 25, 2002

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The sample illustrates how a control, by implementing both a drop source and a drop target can determine whether a zoom operation is desired, or a drag-and-drop operation on a different drop target should be performed. In addition, the control is still able to distinguish between simple mouse clicks in the control, a drag-and-drop/zoom operation being initiated, and a drag-and-drop versus a zoom operation being performed.

Also, the DragDropZoom() function implemented by the control can take a bit flag to signify whether a zoom operation is possible or not based on some external conditions. When you use this member function and the bit flag, a handler for the WM_LBUTTONDOWN message could be written as the following:
   LRESULT CDnDCtrl::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)   {	DWORD dwEffect;	IDataObject *pDataObject;	IDropSource *pDropSource;	QueryInterface(__uuidof(IDataObject), reinterpret_cast<void**>(&pDataObject));	QueryInterface(__uuidof(IDropSource), reinterpret_cast<void**>(&pDropSource));			DoDragDropZoom(		pDataObject,		pDropSource, 		DROPEFFECT_COPY | DROPEFFECT_MOVE | (m_bEnableZoom ? DROPEFFECT_ZOOM : 0), 		&dwEffect	);	if (dwEffect == DROPEFFECT_MOVE)		put_Content(NULL);	// Clean up:	pDataObject->Release();	pDropSource->Release();	return 0;   }				
The member function DoDragDropZoom() then calls virtual member functions OnMouseClick(), OnZoom() or OnDrop() depending on the outcome of the drag drop operation.

(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Cosmin Radu, Microsoft Corporation.

DnDZoom Dndzoomvcnet
Properties

Article ID: 247072 - Last Review: 02/28/2014 00:29:33 - Revision: 7.0

  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • kbnosurvey kbarchive kbhowto kbinfo kbuidesign kbfile kbdragdrop kbctrl kbcollectionclass kbdataobject KB247072
Feedback