mann das gibt doch nicht

Hi all,

I am trying to implement Drag and Drop in a wxTreeCtrl, using
EVT_TREE_BEGIN_DRAG and EVT_TREE_END_DRAG.

With GTK2 it works fine. With MSW, I get the following error - 'Image list
must not be null in EndDrag'.

I do not use images in my tree control. After some hunting, I found the
following lines from XMLtreeview in the demo -

            # Trees need an image list to do DnD...
            self.il = wxImageList(16,16)
            self.SetImageList(self.il)

I copied these lines into my program, and lo and behold, it worked.

Then I found a side-effect. My application uses a single top-level frame,
which displays a menu. Each time an option is selected, a new frame is
created, as a child of the top frame. When the option is closed, the child
frame is destroyed and control is passed back to the menu.

If I run my program the first time, the tree looks normal. If I exit the
program and return to the menu, and then enter the program again, an image
appears next to all the levels in the tree. The program has a toolbar with a
number of icons, and it takes the first icon as the image to use for all the
levels.

I have tried the RemoveAll() method of wxImageList, and I have tried setting
initialCount to 0, but the image still appears. I tried setting the size of
the wxImageList to (0,0), but then the original error message reappeared.

Does anyone have any suggestions?

Platform is Windows 2000, Python 2.2.2, wxPython 2.4.0.2u.

TIA

Frank Millman

Frank Millman wrote:

If I run my program the first time, the tree looks normal. If I exit
the program and return to the menu, and then enter the program again,
an image appears next to all the levels in the tree. The program has
a toolbar with a number of icons, and it takes the first icon as the
image to use for all the levels.

I have tried the RemoveAll() method of wxImageList, and I have tried
setting initialCount to 0, but the image still appears. I tried
setting the size of the wxImageList to (0,0), but then the original
error message reappeared.

Does anyone have any suggestions?

Does the new frame also have a tree? Does it use the same image list?
Is there anything else that could cause the C++ image list to be
destroyed when the child frame closes?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!