From 192258889499e769f0359aa6c0b94732adb6b880 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 27 May 2010 17:07:40 +0000 Subject: [PATCH] Fall back on using tree/list control item text in wxDragImage. 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 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/msw/dragimag.cpp b/src/msw/dragimag.cpp index bed8aea3fe..27e5c366c2 100644 --- a/src/msw/dragimag.cpp +++ b/src/msw/dragimag.cpp @@ -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 -- 2.45.2