tradewright / tabcontrol-extra

An improved TabControl for Windows Forms (.Net)
Other
31 stars 8 forks source link

Drag'n'drop was broken #7

Open wmjordan opened 3 years ago

wmjordan commented 3 years ago

The point passed to GetActiveTabIndex should be the client coordinate. Thus the corresponding code in TabControlExtra.OnDragOver should be:

var dragPoint = new Point(drgevent.X, drgevent.Y);
var tabPoint = this.PointToScreen(Point.Empty);
dragPoint.Offset(-tabPoint.X, -tabPoint.Y);
if (this.GetActiveTab(dragPoint) == dragTab) {
    return;
}

int insertPoint = this.GetActiveIndex(dragPoint);
if (insertPoint < 0) return;
rlktradewright commented 3 years ago

Thank you, well spotted.

But is there a reason not to simply use:

var mousePosition = this.PointToClient(new Point(drgevent.X, drgevent.Y));
if (this.GetActiveTab(mousePosition) == dragTab) {
    return;
}

int insertPoint = this.GetActiveIndex(mousePosition);
if (insertPoint < 0) return;
wmjordan commented 3 years ago

Oh, thank you for replying. Long time no program with WinForm :)

You are right.

rlktradewright commented 3 years ago

I just wanted to say that I have some other concerns about the current drag-and-drop implementation.

I'll probably release a new version soon just to fix the immediate issue here, and then have a more considered go at it.