Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Autioscroll while dragging CListCtrl

Posted on 1997-12-23
7
Medium Priority
?
819 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 140 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

610 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