Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Drag and Drop Collapse All
Subject Author Date
Eddie Judson Nov 20, 2006 - 11:49 PM

Hi,
I have a class derived from CExtTreeGridWnd and am trying to implement drag and drop functionality. My problem is that OnGbwDataDndDo is never fired in my class. Here is the implementation could you tell me what I am doing wrong?

CDrawFieldsGrid::CDrawFieldsGrid(void)
{
    HoverEventsSet( true, false );
    HoverHighlightSet( true, false, false, false, true, true );
    BseModifyStyle( 0, __EGWS_BSE_EDIT_CELLS_INNER , false );
}

CDrawFieldsGrid::~CDrawFieldsGrid(void)
{
}
bool CDrawFieldsGrid::OnGbwDataDndIsAllowed() const
{
    ASSERT_VALID( this );
    return true;
}
void CDrawFieldsGrid::OnGbwDataDndDo(
    const CExtGridHitTestInfo & htInfo
    )
{
    ASSERT_VALID( this );
    htInfo;
    TRACE2(
        "CExtGridBaseWnd::OnGbwDataDndDo(%d,%d)\n",
        htInfo.m_nColNo,
        htInfo.m_nRowNo
        );
}

Regards,
Eddie

Technical Support Nov 21, 2006 - 11:26 AM

It seems you may have forgotten to override the CExtGridWnd::OnGbwDataDndIsAllowed() virtual method and simply return true in it. This turns on data drag-and-drop start events in the grid window and CExtGridWnd::OnGbwDataDndDo() will be invoked. Here is the related FAQ:

How to implement drag-and-drop for inner cells in my grid?.

Eddie Judson Nov 21, 2006 - 11:41 PM

Ummmm.... if you look at the class implementation you will see I have overridden OnGbwDataDndIsAllowed

This is it--->
bool CDrawFieldsGrid::OnGbwDataDndIsAllowed() const
{
ASSERT_VALID( this );
return true;
}

Technical Support Nov 23, 2006 - 9:49 AM

The OnGbwDataDndIsAllowed() virtual method will not be invoked if you have not enabled any cell selection type in the grid window. You can specify the selection type using the SiwModifyStyle() method. The following selection types are defined in the ExtScrollWnd.h file:

// basic selection/focus type
#define __EGBS_SFB_NONE                    0x00000000L
#define __EGBS_SFB_CELLS                   0x00001000L
#define __EGBS_SFB_FULL_ROWS               0x00002000L
#define __EGBS_SFB_FULL_COLUMNS            0x00003000L
#define __EGBS_SFB_MASK                    0x00003000L
// allow multiple row/column/cell selection
#define __EGBS_SFM_ROWS                    0x00000800L
#define __EGBS_SFM_COLUMNS                 0x00008000L
#define __EGBS_SFM_MASK                    (__EGBS_SFM_ROWS|__EGBS_SFM_COLUMNS)
// enabled multiple selection types
#define __EGBS_SFM_CELLS_H                 (__EGBS_SFB_CELLS|__EGBS_SFM_COLUMNS)
#define __EGBS_SFM_CELLS_V                 (__EGBS_SFB_CELLS|__EGBS_SFM_ROWS)
#define __EGBS_SFM_CELLS_HV                (__EGBS_SFB_CELLS|__EGBS_SFM_COLUMNS|__EGBS_SFM_ROWS)
#define __EGBS_SFM_FULL_ROWS               (__EGBS_SFB_FULL_ROWS|__EGBS_SFM_ROWS)
#define __EGBS_SFM_FULL_COLUMNS            (__EGBS_SFB_FULL_COLUMNS|__EGBS_SFM_COLUMNS)
// any selection mask
#define __EGBS_SF_MASK                     (__EGBS_SFB_MASK|__EGBS_SFM_MASK)
The first four __EGBS_SFB_*** styles define general selection types and other styles are based on them. The __EGBS_SFB_NONE style is used in the grid by default and it does not allow you to start any drag-and-drop. We will add this detail to the FAQ about drag-and-dropping cells.

Eddie Judson Nov 24, 2006 - 4:03 AM

Hi I have added the basic selection and am still not getting the OnGbwDataDndDo event firing, following is my implementation: Can you help me out?

#include "StdAfx.h"
#include ".\drawfieldsgrid.h"

CDrawFieldsGrid::CDrawFieldsGrid(void)
{
    HoverEventsSet( true, false );
    HoverHighlightSet( true, false, false, false, true, true );
    SiwModifyStyle(__EGBS_SFB_CELLS,0,false);
    BseModifyStyle( 0, __EGWS_BSE_EDIT_CELLS_INNER , false );
    
    
}

CDrawFieldsGrid::~CDrawFieldsGrid(void)
{
}

bool CDrawFieldsGrid::OnGbwDataDndIsAllowed() const
{
    ASSERT_VALID( this );
    return true;
}

void CDrawFieldsGrid::OnGbwDataDndDo(
    const CExtGridHitTestInfo & htInfo
    )
{
    ASSERT_VALID( this );
    htInfo;
    TRACE2(
        "CExtGridBaseWnd::OnGbwDataDndDo(%d,%d)\n",
        htInfo.m_nColNo,
        htInfo.m_nRowNo
        );
}

Technical Support Nov 24, 2006 - 12:59 PM

You are invoking a set of CExtGridWnd class methods in the CDrawFieldsGrid::CDrawFieldsGrid() constructor. But the CDrawFieldsGrid object at that time is only in the memory and it is not connected to any HWND window handle. So you should invoke these methods in the CDrawFieldsGrid::OnCreate() method instead. Here is a very simple sample you can download from our site:

test_grid_start_drag_and_drop

Eddie Judson Nov 24, 2006 - 4:51 PM

Thank you for your prompt reply, worked nicely.