List Control with OLE Drag '& Drop
Posted
by Jean Claude Dauphin
on November 9th, 2000
Features
This extended list control allow OLE drag and drop between list controls. The programmer can enable/desable local drag and drop of list items inside the same control, automatic scrolling and the removing of dragged items from the source list.Control Usage
- Initialize the OLE libraries in the application InitInstance member function:
- Insert the #include "DDListCtrl.h" in the dialog C++ file which contains the List Ctrls.
- In the OnInitDialog member function of the dialog, initialize and customize the list controls initialization according to the following template:
BOOL CDdDemoApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
// Call this when using MFC in a shared DLL
Enable3dControls();
#else
// Call this when linking to MFC statically
Enable3dControlsStatic();
#endif
//-------------------------
// Initialize OLE libraries
//-------------------------
if (!AfxOleInit())
return FALSE;
BOOL CDdDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//.................................
//---------------------------->Downloads
Download source - 9 KbDownload demo project - 32 Kb

Comments
Better not to use WM_TIMER
Posted by Legacy on 01/16/2002 12:00amOriginally posted by: Robert Dyer
Because timer messages occur ONLY when the message queue is empty, they are not reliable to use during a drag and drop operation. I found the timer messages were sometimes not getting sent and hence the scrolling did not occur.
The idea of course here is to make sure scrolling does
not happen any faster than one line per 300 milliseconds.
A better approach that also uses less code and fewer resources is to use the WIN32 API function GetTickCount
in the OnDragOver method of the COleListCtrlDropTarget
class in DDListCtrl.cpp. Just keep track of the previous tick count when scrolling occurred, and scroll only when the difference between the current and previous tick counts exceeds 300 milliseconds.
Then there is no need for calls to SetTimer and KillTimer, and you can remove the OnTimer method of CDDListCtrl.
Reply