Solved

Autioscroll while dragging CListCtrl

Posted on 1997-12-23
7
788 Views
Last Modified: 2013-11-19
In my CListView I have implemented items drag&drop (OnBeginDrag, etc..)
Now I need that the CListCtrl scrolls automatically when the item is dragged above or below client area. How??
0
Comment
Question by:winmeister
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1312951
OLE itself scrolls target window when mouse pointer within a boder approximately 4 pixels(defined in WIN.INI). I suppose tt gets window using WindowFromPoint and calls ScrollWindow(Ex)
0
 
LVL 1

Author Comment

by:winmeister
ID: 1312952
My CListCtrl is not an OLE element. It doesn't scroll by itself.
0
 
LVL 7

Expert Comment

by:galkin
ID: 1312953
Implement drop target using COleDropTarget MFC class. Call its register in CListCtrl derved class OnCreate message handler. By such a way you registeryou list control as OLE drop target. Now it will be scrolled.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:winmeister
ID: 1312954
Sorry galkin, but I just did that way and it still doesn't work.
I have create a class instance (private) of COleDropTarget:

COleDropTarget m_dropTarget;

and then I have added this method:

int CListViewEx::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
      if (CListView::OnCreate(lpCreateStruct) == -1)
            return -1;
      
      // TODO: Add your specialized creation code here
      m_dropTarget.Register(this);
      return 0;
}

...but when dragging an item, the list doesn't scroll. I am dragging items with OnBeginDrag method.

0
 
LVL 7

Expert Comment

by:galkin
ID: 1312955
Did you specify DROPEFFECT_SCROLL in COleDragSource DoDragDrop?
0
 
LVL 1

Author Comment

by:winmeister
ID: 1312956
Aaah!
I am not using that approach. I have started from the ROWLIST example in VC++ CDROM. If you look at that example, the item dragging is obtained by overriding OnBeginDrag, OnMouseMove  and OnLButtonUp methods. No OLE support.
My application is almost finished and I have just this open item, so I don't want to change all the philosophy.
Besides this, I don't think it is necessary an OLE support to move items in a CListCtrl!

0
 
LVL 1

Accepted Solution

by:
richhxb earned 70 total points
ID: 1312957
You have to create your own CListDropTarget class derived
from COleDropTarget.

class CListDropTarget : public COleDropTarget
{
public:
    CListDropTarget()
    {
      ms_bBeginDrop=FALSE;
      ms_pListCtl=NULL;
    }

    BOOL        Register(CListViewEx* pList);
    BOOL        OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
    DROPEFFECT  OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
    void        OnDragLeave(CWnd* pWnd);
    DROPEFFECT  OnDragOver(CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
      DROPEFFECT  OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point);

private:
    BOOL        ms_bBeginDrop;
    CListViewEx*  ms_pListCtl;
};

First, override Register function in CListDropTarget.

BOOL CListDropTarget::Register(CListViewEx* pListView)
{
    ms_pListCtl=pListView;
    return COleDropTarget::Register(pListView);
}

Then, register your ListView as a drop target in your
own CListViewEx::OnCreate function.

CListDropTarget m_dropTarget;
m_dropTarget.Register(this);

Last, you should also override OnDragScroll function
in your CListDropTarget class.

DROPEFFECT CListDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint point)
{
    //Since pWnd is a kind of CView, we let COleDropTarget to handle it.
      if (pWnd->IsKindOf(RUNTIME_CLASS(CView)))
            return COleDropTarget::OnDragScroll(pWnd,dwKeyState,point);
}

Now it should works.




0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 101
Whole sheet autoscrub still needed 19 53
fizzArray  challenge 1 107
no14 challenge 14 72
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question