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 » CExtTabMdiWnd -> which tab? -> CView Collapse All
Subject Author Date
Robert Webb Aug 19, 2009 - 3:07 AM

Hi,


I want to be able to drag and drop items from a tree control to an MDI tab.  Calling WindowFromPoint() returns a CWnd* which I can DYNAMIC_DOWNCAST to various things, such as a CExtTabMdiWnd.  But once I have the CExtTabMdiWnd, how do I find out which tab was clicked on?  That is, how do I find the tab given a CPoint?  And how do I find out which CView that represents?  I couldn’t see any useful methods to help with this.


Thanks,


Rob.

Technical Support Aug 20, 2009 - 9:47 AM

We implemented the insertion mark in the CExtTreeCtrl control. Here is the source code update:

http://www.prof-uis.com/download/forums/tmp/TreeCtrlWithInsertionMarkForRobertWebb.zip


Technical Support Aug 20, 2009 - 7:48 AM

The tab items have the LPARAM user defined property. It’s the HWND handle of MDI child frame window in case of MDI tabs:

CExtTabMdiWnd * pWndMdiTabs = . . .
LONG nCurSel =  pWndMdiTabs->SelectionGet();
      if( nCurSel < 0 L )
            return . . .
HWND hWnd =  pWndMdiTabs->ItemLParamGet( nCurSel );
      ASSERT( hWnd != NULL && ::IsWindow(hWnd) );
CWnd * pWndMdiChildFrame = CWnd::FromHandlePermanent( hWnd );
CWnd * pWndViewInsideMdiChildFrame = pWndMdiChildFrame->GetDlgItem( AFX_IDW_PANE_FIRST );

The update version of the
 CExtTreeCtrl::EnableItem()</code> method repaints enabled/disabled items.
<pre>void CExtTreeCtrl::EnableItem(
      HTREEITEM hti,
      bool bEnable // = true
      )
{
      ASSERT_VALID( this );
      if( hti == NULL )
            return;
TREEITEMINFO_t & _TII = TreeItemInfoGet( hti );
      if( ( _TII.m_bDisabled && bEnable ) || ( (!_TII.m_bDisabled) && (!bEnable) ) )
            return;
      _TII.m_bDisabled = ! bEnable;
      if( GetSafeHwnd() == NULL )
            return;
CRect rcItemEntire;
      TreeItemRectGet( hti, rcItemEntire, e_tirt_entire );
      if( rcItemEntire.IsRectEmpty() )
            return;
CRect rcClient;
      GetClientRect( &rcClient );
      if(         ( rcClient.top <= rcItemEntire.top && rcItemEntire.top <= rcClient.bottom )
            ||    ( rcClient.top <= rcItemEntire.bottom && rcItemEntire.bottom <= rcClient.bottom )
            )
            InvalidateRect( &rcItemEntire );
}

The SetInsertMark() method is not implemented yet. We didn’t implemented it because Prof-UIS classes use the non-rectangular window with form of red arrows displayed over other windows to highlight the dropping target. These red arrows are used instead of any insertion marks. We can assume the SetInsertMark() method is a feature request.


Robert Webb Aug 20, 2009 - 9:19 PM

Thanks, although it seems this version of EnableItem() acts a little worse than the old one.  Previously I called Invalidate() for the tree after EnableItem(), which made sure it got redrawn right.  Now even this leaves all items shown as enabled!


It may be something to do with me using this call: AutoDisableChildrenItemsSet().  I am calling EnableItem() on the root node in order to enable/disable the entire tree.  Maybe you are only invalidating the root node.  But I don’t know why my subsequent call to Invalidate() would not redraw it properly anyway.


Oh, and you didn’t answer this: "Is there an article about drag/drop with ProfUIS?".  In particular I don’t understand how to do it in conjunction with a tree control.


Thanks,


Rob.

Technical Support Aug 22, 2009 - 11:38 AM

There was a typo in the CExtTreeCtrl::EnableItem() method. We are sorry for this inconvenience. Here is the correct version:

void CExtTreeCtrl::EnableItem(
      HTREEITEM hti,
      bool bEnable // = true
      )
{
      ASSERT_VALID( this );
      if( hti == NULL )
            return;
TREEITEMINFO_t & _TII = TreeItemInfoGet( hti );
      if( ( _TII.m_bDisabled && (!bEnable) ) || ( (!_TII.m_bDisabled) && bEnable ) )
            return;
      _TII.m_bDisabled = ! bEnable;
      if( GetSafeHwnd() == NULL )
            return;
CRect rcItemEntire;
      TreeItemRectGet( hti, rcItemEntire, e_tirt_entire );
      if( rcItemEntire.IsRectEmpty() )
            return;
CRect rcClient;
      GetClientRect( &rcClient );
      if(         ( rcClient.top <= rcItemEntire.top && rcItemEntire.top <= rcClient.bottom )
            ||    ( rcClient.top <= rcItemEntire.bottom && rcItemEntire.bottom <= rcClient.bottom )
            )
            InvalidateRect( &rcItemEntire );
}
The drag-n-drop number one in Windows world is OLE drag-n-drop. It’s used in the FormEditor sample application. It’s used by customizable toolbars and menus in Prof-UIS. It’s supported by Prof-UIS grid controls starting from version 2.85 and it’s demonstrated in the FormulaGrid sample application. It’s simple. It’s convenient. It can work between threads and processes. It’s so easy so you can either use Win32 or MFC APIs. It’s equally easy to use COleDataSource / COleDropSource / COleDropTargent classes from MFC or to implement IDataSource / IDropSource / IDropTargent interfaces from Win32. The OLE drag-n-drop and clipboard support code is always in intersected. If you decided to code one of these features, then you can code both of them. Here is the theoretical basics:

http://msdn.microsoft.com/en-us/library/96826a87(VS.80).aspx

There are many articles on the Internet like these:

http://www.codeproject.com/KB/shell/dragdrop.aspx?msg=180749
http://www.codeproject.com/KB/clipboard/dragsource.aspx

Technical Support Aug 19, 2009 - 2:32 PM

Please take a look at the FormEditor sample application. It implements drag-n-drop from the toolbox control into MDI form view window. You should use the same OLE drag-n-drop in your application. It the most widely used drag-n-drop implementation because it’s simple and convenient. The MDI tabs and resizable control bar tabs in Prof-UIS support dragging-over event handling and perform tab item selection automatically.

Robert Webb Aug 20, 2009 - 2:38 AM

Hmm, I don’t really understand how the FormEditor code is working.  Is there an article about drag/drop with ProfUIS?


I initially looked at doing it the OLE way, but couldn’t see how to use it when dragging items from a tree control, so I started doing it another way instead.  This is mostly working, except for a few things:


(1) Given the index of a tab on the MDI bar, how do I find the matching CView?  Seems like this should be easy, but I can’t find a way.


(2) CExtTreeCtrl::SetInsertMark() doesn’t seem to work.  No insertion mark is drawn.


(3) CExtTreeCtrl::EnableItem() doesn’t cause the tree to be redrawn.


Thanks,


Rob.