ListCtrl Drag/Drop Differences Between Windows XP and Windows 7

I’ve got some list ctrls set up with drag and drop and working. I’ve noticed a behavior difference between XP and 7. In order to begin a drag in XP, you have to actually drag the text label. If you don’t, it just draws a selection rectangle. In Windows 7, you can drag from anywhere in the column. I’ve attached a screenshot from XP showing the rectangle. Also attached is my sample code. My code doesn’t implement a Drop Target as it’s not needed for this demonstration.

Is there any way to make XP behave like Windows 7? It’s counter-intuitive to have to drag the text label instead of anywhere on the row. I’m guessing this is just the behavior of the stock listctrl and there’s no way to override, but I figured I’d throw it out there in case I overlooked something.

For reference I’m running Windows 7 x64 and Windows XP 32bit, both with Python 2.5 and wxPython 2.8.11.0 (msw-unicode).

drag_test.py (1.29 KB)

xp.PNG

You are correct, since you are using the listctrl's EVT_LIST_BEGIN_DRAG event then this is a behavior provided by the native control. You can probably work around it by fully implementing the DnD yourself. Catch the appropriate mouse events and use HitTest know which item you are on, then call DoDragDrop after you sense that a drag of more than a few pixels has been started.

···

On 3/9/11 12:49 PM, Kyle Rickey wrote:

I've got some list ctrls set up with drag and drop and working. I've
noticed a behavior difference between XP and 7. In order to begin a drag
in XP, you have to actually drag the text label. If you don't, it just
draws a selection rectangle. In Windows 7, you can drag from anywhere in
the column. I've attached a screenshot from XP showing the rectangle.
Also attached is my sample code. My code doesn't implement a Drop Target
as it's not needed for this demonstration.

Is there any way to make XP behave like Windows 7? It's
counter-intuitive to have to drag the text label instead of anywhere on
the row. I'm guessing this is just the behavior of the stock listctrl
and there's no way to override, but I figured I'd throw it out there in
case I overlooked something.

--
Robin Dunn
Software Craftsman

Sorry for the late response. I'll check into your suggestion.

Thank you,

Kyle

···

On Mar 10, 2:04 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/9/11 12:49 PM, Kyle Rickey wrote:

> I've got some list ctrls set up with drag and drop and working. I've
> noticed a behavior difference between XP and 7. In order to begin a drag
> in XP, you have to actually drag the text label. If you don't, it just
> draws a selection rectangle. In Windows 7, you can drag from anywhere in
> the column. I've attached a screenshot from XP showing the rectangle.
> Also attached is my sample code. My code doesn't implement a Drop Target
> as it's not needed for this demonstration.

> Is there any way to make XP behave like Windows 7? It's
> counter-intuitive to have to drag the text label instead of anywhere on
> the row. I'm guessing this is just the behavior of the stock listctrl
> and there's no way to override, but I figured I'd throw it out there in
> case I overlooked something.

You are correct, since you are using the listctrl's EVT_LIST_BEGIN_DRAG
event then this is a behavior provided by the native control. You can
probably work around it by fully implementing the DnD yourself. Catch
the appropriate mouse events and use HitTest know which item you are on,
then call DoDragDrop after you sense that a drag of more than a few
pixels has been started.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org