From f5d91155989d9bc5eca1f0240346ce26817e3421 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 17 May 2012 14:49:32 +0000 Subject: [PATCH] ExtendedNotebook: Do not drag, if tabs have been added/changed/removed while mouse pressed git-svn-id: trunk@37306 - --- components/lazcontrols/extendednotebook.pas | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/components/lazcontrols/extendednotebook.pas b/components/lazcontrols/extendednotebook.pas index 499f56b673..16d67b723d 100644 --- a/components/lazcontrols/extendednotebook.pas +++ b/components/lazcontrols/extendednotebook.pas @@ -74,6 +74,9 @@ type Y: Integer); override; procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure CNNotify(var Message: TLMNotify); message CN_NOTIFY; + procedure RemovePage(Index: Integer); override; + procedure InsertPage(APage: TCustomPage; Index: Integer); override; + procedure CaptureChanged; override; procedure DoStartDrag(var DragObject: TDragObject); override; procedure DoEndDrag(Target: TObject; X,Y: Integer); override; procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; @@ -116,6 +119,7 @@ Begin FMouseWaitForDrag := False; DragCursor := crDrag; FDragOverIndex := -1; + FDraggingTabIndex := -1; FDragOverTabRect := Rect(0, 0, 0, 0); FDragNextToTabRect := Rect(0, 0, 0, 0); end; @@ -167,8 +171,8 @@ Begin FMouseDownY := Y; FTriggerDragX := GetSystemMetrics(SM_CXDRAG); FTriggerDragY := GetSystemMetrics(SM_CYDRAG); + MouseCapture := True; end; - MouseCapture := True; end; procedure TExtendedNotebook.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); @@ -194,6 +198,12 @@ end; procedure TExtendedNotebook.CNNotify(var Message: TLMNotify); Begin + if (Dragging or (FDraggingTabIndex >= 0)) and + ( (Message.NMHdr^.code = TCN_SELCHANGING) or + (Message.NMHdr^.code = TCN_SELCHANGE) ) + then + CancelDrag + else if Message.NMHdr^.code = TCN_SELCHANGING then Begin if (fTabDragMode = dmAutomatic) and (not FMouseWaitForDrag) then FMouseDownIndex := TabIndexAtClientPos(ScreenToClient(Mouse.CursorPos)); @@ -202,6 +212,29 @@ Begin inherited CNNotify(Message); end; +procedure TExtendedNotebook.RemovePage(Index: Integer); +begin + CancelDrag; + FMouseDownIndex := -1; + FMouseWaitForDrag := False; + inherited RemovePage(Index); +end; + +procedure TExtendedNotebook.InsertPage(APage: TCustomPage; Index: Integer); +begin + CancelDrag; + FMouseDownIndex := -1; + FMouseWaitForDrag := False; + inherited InsertPage(APage, Index); +end; + +procedure TExtendedNotebook.CaptureChanged; +begin + FMouseDownIndex := -1; + FMouseWaitForDrag := False; + inherited CaptureChanged; +end; + procedure TExtendedNotebook.DoStartDrag(var DragObject: TDragObject); begin {$IFDEF ExtNBookDebug}debugln(['TExtendedNotebook.DoStartDrag FDraggingTabIndex=', FDraggingTabIndex]);{$ENDIF}