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 General Discussion » CExtPropertyCategory drag and drop from CExtPropertyGridCtrl to CExtGridWnd Collapse All
Subject Author Date
Nathan Explosions Jun 15, 2007 - 8:46 AM

Greetings.

Please help me to understand, how to implement the dragging of CExtPropertyCategory from CExtPropertyGridCtrl to CExtGridWnd?

I have already implemented drag and drop of CExtGridWnd cells to CExtPropertyGridCtrl property grid with the help of OLE and CExtGridWnd::OnGbwDataDndDo() method, but now I don’t understand what I should do to detect the start of property category dragging in case of CExtPropertyCategory class...

I also would like to ask how to update a CExtControlBar after its properties were changed. For example, if I make the g_bTabsAtTop property true and update the CExtControlBar with methods like ::RepositionBars(0, 0xFFFF, 0) and ::RedrawWindow(), the control bar will be updated, although not completely - the tabs would be visible at top and at bottom parts of control bar. It is possible to hide the control bar and to show it afterwards to solve this issue, but I hope there is a better solution, which I have missed.

Thank you very much for your time.

Nathan Explosions Jun 18, 2007 - 3:48 AM

Thank you very very much! I am very grateful for your help.

Technical Support Jun 17, 2007 - 11:59 AM

The CExtGridBaseWnd::OnGbwDataDndDo() virtual method is invoked in CExtGridWnd, CExtTreeGridWnd and CExtReportGridWnd windows when the user starts drag-n-dropping. You need to derive a class from one of these classes and override this method, and the following virtual methods:

1) The CExtGridBaseWnd::OnGbwDataDndIsAllowed() virtual method should be overridden and return true value to enable the event when drag-n-drop starts in the grid window.

2) The CExtGridBaseWnd::OnGbwDataDndCanStart()virtual method should be overridden if you want to disable drag-n-drop for particular data cells.

The drag-n-drop for the property grid control is a bit different than for grids listed above because the CExtPropertyGridCtrl class is not derived from those classes. The CExtPropertyGridCtrl class is a container for one or more tree grid windows displaying property values and some other controls like a toolbar, a combo box and a tip bar. The tree grids in the property grid control are based on the CExtPropertyGridWnd class which is derived from CExtTreeGridWnd. By default, the two tree grids are created: CExtPropertyGridWndCategorized and CExtPropertyGridWndSorted. If you need to handle drag-n-drop events in these grids, then you should override the CExtPropertyGridCtrl::OnPgcCreateGrids() virtual method. Your method should be similar to original listed below, but it should create your own CExtPropertyGridWndCategorized-derived and CExtPropertyGridWndSorted-derived classes:

bool CExtPropertyGridCtrl::OnPgcCreateGrids()
{
      ASSERT_VALID( this );
      try
      {
            CExtPropertyGridWndCategorized * pGridCategorized =
                  new CExtPropertyGridWndCategorized( this );
            pGridCategorized->m_bAutoDeleteWindow = true;
            if( ! pGridCategorized->Create(
                        this,
                        __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED,
                        true
                        )
                  )
            {
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED;
            }
            CExtPropertyGridWndSorted * pGridSorted =
                  new CExtPropertyGridWndSorted( this );
            pGridSorted->m_bAutoDeleteWindow = true;
            if( ! pGridSorted->Create(
                        this,
                        __EXT_MFC_ID_PROPERTY_GRID_SORTED
                        )
                  )
            {
                  ASSERT( FALSE );
                  throw __EXT_MFC_ID_PROPERTY_GRID_SORTED;
            }
      }
      catch( ... )
      {
            return false;
      }
      return true;
}
Your tree grids should handle drag-n-drop events like described above. You should use the CExtPropertyGridWnd::PropertyItemToTreeItem() and CExtPropertyGridWnd::PropertyItemToTreeItem() methods for conversion between property category/value pointers and HTREEITEM handles that are used by the CExtTreeGridWnd class methods. You should use the CExtTreeGridWnd::ItemGetByVisibleRowIndex() and CExtTreeGridWnd::ItemGetVisibleIndexOf() methods for conversion between HTREEITEM handles and plain row indices that are used by the CExtGridWnd class methods. The CExtTreeGridWnd::ItemGetVisibleIndexOf() method returns a negative value if the specified HTREEITEM row handle corresponds to the tree row which have collapsed parent row.