]> git.saurik.com Git - wxWidgets.git/commitdiff
Fall back on using tree/list control item text in wxDragImage.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 May 2010 17:07:40 +0000 (17:07 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 27 May 2010 17:07:40 +0000 (17:07 +0000)
Use the item text instead of its image if it doesn't have any when creating a
wxDragImage from a wxTreeCtrl or wxListCtrl item instead of just failing.

Closes #4390.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64415 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/dragimag.cpp

index bed8aea3fe8932f1f585ada291ac75a4c57cf9a8..27e5c366c2efda5d929d35ce7de1af830a7aea70 100644 (file)
@@ -250,7 +250,13 @@ bool wxDragImage::Create(const wxTreeCtrl& treeCtrl, wxTreeItemId& id)
         ImageList_Destroy(GetHimageList());
     m_hImageList = (WXHIMAGELIST)
         TreeView_CreateDragImage(GetHwndOf(&treeCtrl), (HTREEITEM) id.m_pItem);
-    return m_hImageList != 0;
+    if ( !m_hImageList )
+    {
+        // fall back on just the item text if there is no image
+        return Create(treeCtrl.GetItemText(id));
+    }
+
+    return true;
 }
 #endif
 
@@ -261,8 +267,17 @@ bool wxDragImage::Create(const wxListCtrl& listCtrl, long id)
     if ( m_hImageList )
         ImageList_Destroy(GetHimageList());
     POINT pt;
-    pt.x = 0; pt.y = 0;
-    m_hImageList = (WXHIMAGELIST) ListView_CreateDragImage((HWND) listCtrl.GetHWND(), id, & pt);
+    pt.x =
+    pt.y = 0;
+    m_hImageList = (WXHIMAGELIST)
+        ListView_CreateDragImage(GetHwndOf(&listCtrl), id, &pt);
+
+    if ( !m_hImageList )
+    {
+        // as for wxTreeCtrl, fall back on dragging just the item text
+        return Create(listCtrl.GetItemText(id));
+    }
+
     return true;
 }
 #endif